当前位置:网站首页>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;
}
边栏推荐
- 运行时修改Universal Render Data
- Insurance can also be bought together? Four risks that individuals can pool enough people to buy Medical Insurance in groups
- Using qdomdocument to manipulate XML files in QT
- Overview of AOSP ~ WiFi architecture
- E - Average and Median(二分)
- mysql学习笔记--单张表上的增删改查
- Migrate Oracle database from windows system to Linux Oracle RAC cluster environment (1) -- migrate data to node 1
- Internship: use of SVN
- 记一次beego通过go get命令后找不到bee.exe的坑
- Software testing salary in first tier cities - are you dragging your feet
猜你喜欢

jwt

LeetCode 210:课程表 II (拓扑排序)
![[live review] battle code pioneer phase 7: how third-party application developers contribute to open source](/img/ad/26a302ca724177e37fe123f8b75e4e.png)
[live review] battle code pioneer phase 7: how third-party application developers contribute to open source

Difference between left join on and join on

【STL源码剖析】配置器(待补充)

保险也能拼购?个人可以凑够人数组团购买医疗保险的4大风险

Talking about the advantages of flying book in development work | community essay solicitation

Software testing weekly (issue 77): giving up once will breed the habit of giving up, and the problems that could have been solved will become insoluble.

PyTorch学习笔记(七)------------------ Vision Transformer

DDD concept is complex and difficult to understand. How to design code implementation model in practice?
随机推荐
14 bs对象.节点名称.name attrs string 获取节点名称 属性 内容
The Oracle 11g RAC cluster database cannot be started due to directory permission errors
Internship: use of SVN
Difference between left join on and join on
ERROR日志格式与注意点
计算机三级(数据库)备考题目知识点总结
Talking about the advantages of flying book in development work | community essay solicitation
Pytorch learning notes (VII) ------------------ vision transformer
NPM package publishing tutorial
国信金太阳打新债步骤 开户是安全的吗
@PostConstruct
Solution of separating matlab main window and editor window into two interfaces
目录权限错误导致 Oracle 11g rac 集群数据库无法启动的问题
Folding screen will become an important weapon for domestic mobile phones to share the apple market
Migrate Oracle database from windows system to Linux Oracle RAC cluster environment (3) -- set the database to archive mode
Is it out of reach to enter Ali as a tester? Here may be the answer you want
C # realizes crystal report binding data and printing
Pit entry machine learning: I. Introduction
Network planning | [four network layers] knowledge points and examples
高速缓存Cache详解(西电考研向)