当前位置:网站首页>New solution of 202112-2 sequence query
New solution of 202112-2 sequence query
2022-06-25 02:52:00 【Liu Xue】
#include <stdio.h>
int main()
{
//n, Enter on behalf of the next line n Number ,N There are representatives of N A serial number , Attention from 0 Start
int n, N;
scanf("%d %d", &n ,&N);
int B[N] = {
0};
int r;
int k;
int res = 0;
int i, j;
int sum = 0;
// Calculate the scale factor
r = N/(n+1);
int g[N] = {
0}; // Deposit g(X)
// Be careful A[0] Fixed for 0, So from A[1] Start saving , To A[n] end :
for(i=1; i<=n; i++)
{
scanf("%d", &j);
B[j]++; // Mark the position to change , Temporary use B Record
}
for(i=1; i<N; i++) //B[0] = 0;
{
B[i] = B[i] + B[i-1]; // Find the real array B namely f(X)
// sum = sum + B[i]; // Sum up
// printf("%d ", B[i]);
}
// printf("\n");
for(i=1; i<N; i++) //g[0] = 0;
{
// Calculation g(x)
g[i] = i/r;
//printf("%d ",g[i]);
}
for(i=1; i<N; i++) //g[0] = 0;
{
if(g[i]>=B[i])
{
k = g[i]-B[i];
}
else k = B[i]-g[i];
res = res + k;
}
printf("%d",res);
return 0;
}
边栏推荐
- Dirvish Chinese document of vim
- 微信小程序获取扫描二维码后携带的参数
- Copilot免费时代结束!学生党和热门开源项目维护者可白嫖
- NPM package publishing tutorial
- Call system function security scheme
- npm包发布详细教程
- Enlightenment of using shadergraph to make edge fusion particle shader
- Redis
- Array - fast and slow pointer in one breath
- 记一次beego通过go get命令后找不到bee.exe的坑
猜你喜欢
Lihongyi, machine learning 6 Convolutional neural network
Getting started with unityshader - Surface Shader
Redis
random list随机生成不重复数
Sumati gamefi ecological overview, element design in the magical world
Can automate - 10k, can automate - 20K, do you understand automated testing?
Introduction to CUDA Programming minimalist tutorial
ProcessOn制作ER过程(自定义)
分布式事务解决方案和代码落地
【STL源码剖析】STL六大组件功能与运用(目录)
随机推荐
After reciting the eight part essay, I won the hemp in June
用向量表示两个坐标系的变换
Network planning | [four network layers] knowledge points and examples
CUDA编程入门极简教程
DSPACE设置斑马线和道路箭头
把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(2)——将数据库转换为集群模式
ProcessOn制作ER过程(自定义)
Migrate Oracle database from windows system to Linux Oracle RAC cluster environment (3) -- set the database to archive mode
ACL access control of squid proxy server
Talking about the advantages of flying book in development work | community essay solicitation
psql 列转行
Getting started with unityshader - Surface Shader
jwt
js正则匹配数字、大小写字母、下划线、中线和点[通俗易懂]
F - Spices(线性基)
[I.MX6UL] U-Boot移植(六) 网络驱动修改 LAN8720A
Refresh mechanism of vie
[STL source code analysis] configurator (to be supplemented)
Migrate Oracle database from windows system to Linux Oracle RAC cluster environment (1) -- migrate data to node 1
DDD concept is complex and difficult to understand. How to design code implementation model in practice?