当前位置:网站首页>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;
}
边栏推荐
- qt打包exe文件,解决“无法定位程序输入点_ZdaPvj于动态链接库Qt5Cored.dll”
- PE文件基础结构梳理
- Array - fast and slow pointer in one breath
- After reciting the eight part essay, I won the hemp in June
- Using qdomdocument to manipulate XML files in QT
- E - Average and Median(二分)
- AI服装生成,帮你完成服装设计的最后一步
- F - spices (linear basis)
- Summary of knowledge points of computer level III (database) test preparation topics
- js正则匹配数字、大小写字母、下划线、中线和点[通俗易懂]
猜你喜欢

yarn : 无法加载文件 C:\Users\xxx\AppData\Roaming\npm\yarn.ps1,因为在此系统上禁止运行脚本

AI clothing generation helps you complete the last step of clothing design

Software testing salary in first tier cities - are you dragging your feet

Pytorch learning notes (VII) ------------------ vision transformer

MATLAB主窗口与编辑器窗口分开为两个界面的解决办法

Folding screen will become an important weapon for domestic mobile phones to share the apple market

Pit entry machine learning: I. Introduction

14 BS object Node name Name attrs string get node name attribute content

记一次beego通过go get命令后找不到bee.exe的坑

Of the seven levels of software testers, it is said that only 1% can achieve level 7
随机推荐
高数 | 精通中值定理 解题套路汇总
Folding screen will become an important weapon for domestic mobile phones to share the apple market
centos7.3修改mysql默认密码_详解Centos7 修改mysql指定用户的密码
How transformers Roberta adds tokens
Pytorch learning notes (VII) ------------------ vision transformer
调用系统函数安全方案
ERROR日志格式与注意点
NPM package publishing tutorial
如何卸载cuda
JS regular matching numbers, upper and lower case letters, underscores, midlines and dots [easy to understand]
CMakeLists中的add_definitions()函数
Charles packet capturing tool
jwt
UnityShader入门精要——表面着色器
Detailed explanation of cache (for the postgraduate entrance examination of XD)
Sumati gamefi ecological overview, element design in the magical world
AOSP ~ WIFI架构总览
It's 2022, and you still don't know what performance testing is?
Array - fast and slow pointer in one breath
PyTorch学习笔记(七)------------------ Vision Transformer