当前位置:网站首页>~5 new solution of CCF 2021-12-2 sequence query
~5 new solution of CCF 2021-12-2 sequence query
2022-07-25 14:04:00 【Ye Xiaobai】
New solution to sequence query
Title Description

Input

Output

The sample input
Examples 1
3 10
2 5 8
Examples 2
9 10
1 2 3 4 5 6 7 8 9
Examples 3
2 10
1 3
Sample output
Examples 1
5
Examples 2
0
Examples 3
6
The subtasks

Source code
70 branch :
#include <iostream>
#include <math.h>
using namespace std;
int main (){
int n,N;
cin>>n>>N;
long double *f=new long double [N+1];
long double *g=new long double [N+1];
long double *t=new long double [N+1];
long double *c=new long double [N+1];
int rate=0;
int temp=0;
int i=0;
int result=0;
int h=0;
int count=0;
int k=0;
f[0]=0;
g[0]=0;
c[0]=0;
t[0]=0;
for (i = 1; i <=n ; i++) {
cin>>temp;
t[i]=temp;
c[i-1]=t[i]-t[i-1];
}
c[i-1]=N-t[i-1];
rate=ceil((double )(N/(n+1)));
for (int j = 0; j < N; j++) {
g[j]= ceil((double )(j/rate));
}
for (int j = 0; j < N; j++) {
if (c[h]!=count){
count++;
}
else{
h++;
k++;
count=1;
}
f[j]=abs(g[j]-k);
}
for (int j = 0; j <N ; j++) {
result+=f[j];
}
cout<<result<<endl;
return 0;
}
About this problem
70 branch All of them are int It's also 70 branch …
边栏推荐
- Alibaba mqtt IOT platform "cloud product circulation" practice - the two esp32 achieve remote interoperability through the IOT platform
- 【Platform IO编译Hifive1-revB】*** [.pio\build\hifive1-revb\src\setupGPIO.o] Error 1的解决办法
- Mongodb源码部署以及配置
- Install oh my Zsh
- CSV文本文件导入excel的四种方法
- NoSQL,关系型数据库,行列数据库对比、类比
- [configure hifive1 revb] the device manager does not recognize the port, and can not connect to j-link via USB
- Practice of online problem feedback module (13): realize multi parameter paging query list
- CDA level1 double disk summary
- CDA level Ⅰ 2021 new version simulation question 2 (with answers)
猜你喜欢

Package management apt, dpkg

Interpretation of featdepth self-monitoring model for monocular depth estimation (Part 2) -- use of openmmlab framework
![Depth estimation self-monitoring model monodepth2 paper summary and source code analysis [theoretical part]](/img/22/17250eabf067b5b1b9b71e6e0ff14e.png)
Depth estimation self-monitoring model monodepth2 paper summary and source code analysis [theoretical part]

Business data analysis of CDA level1 knowledge point summary

OKA通证权益解析,参与Okaleido生态建设的不二之选

Alibaba mqtt IOT platform "cloud product circulation" practice - the two esp32 achieve remote interoperability through the IOT platform

Workplace "digital people" don't eat or sleep 007 work system, can you "roll" them?
![[directory blasting tool] information collection stage: robots.txt, Yujian, dirsearch, dirb, gobuster](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[directory blasting tool] information collection stage: robots.txt, Yujian, dirsearch, dirb, gobuster

The practice of depth estimation self-monitoring model monodepth2 in its own data set -- single card / multi card training, reasoning, onnx transformation and quantitative index evaluation

移动端网站,独立APP,网站排名策略有哪些?
随机推荐
NoSQL,关系型数据库,行列数据库对比、类比
Brush questions - Luogu -p1085 unhappy Jinjin
命名空间与库
Turn off automatic update when brew executes commands
From Anaconda to tensorflow to jupyter, step on the pit and fill it all the way
CDA level Ⅰ 2021 new version simulation question 1 (with answers)
Framework package merge script
Xintang nuc980 set DHCP or static IP
Brush questions - Luogu -p1075 prime factor decomposition
职场「数字人」不吃不睡007工作制,你「卷」得过它们吗?
It is predicted that 2021 will accelerate the achievement of super automation beyond RPA
leetcode202---快乐数
力扣(LeetCode)205. 同构字符串(2022.07.24)
Common problems in the use of wireless vibrating wire acquisition instrument
LabVIEW的内部错误
Nuc980 set up SSH xshell connection
【力扣】645.错误的集合
【学习记录】plt.show()闪退解决方法
Brush questions - Luogu -p1046 Tao Tao picking apples
Brush questions - Luogu -p1161 turn on the light