当前位置:网站首页>~5 ccf 2021-12-2 序列查询新解
~5 ccf 2021-12-2 序列查询新解
2022-07-25 09:19:00 【叶萧白】
题目描述

输入

输出

样例输入
样例1
3 10
2 5 8
样例2
9 10
1 2 3 4 5 6 7 8 9
样例3
2 10
1 3
样例输出
样例1
5
样例2
0
样例3
6
子任务

源代码
70分:
#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;
}
关于这题
70分 其实都是int 也是70分…
边栏推荐
- Interviewer: tell me the difference between redis and mongodb? [easy to understand]
- Unable to start debugging on the web server, the web server failed to find the requested resource
- [GYCTF2020]Node Game
- Idea practical tips --- now change pom.xml (red) to pom.xml (blue)
- 粗柳簸箕细柳斗,谁嫌爬虫男人丑 之 异步协程半秒扒光一本小说
- idea实用tips---如今将pom.xml(红色)改为pom.xml(蓝色)
- 『怎么用』装饰者模式
- Ranking of data results in MySQL
- Nacos启动报错Unable to start web server
- MySQL的索引、视图与事务
猜你喜欢

idea中将lib目录下的jar包加入到项目中

Programmers can't SQL? Ashes Engineer: all waiting to be eliminated! This is a must skill!

『每日一问』ReentrantLock加锁解锁

matplotlib数据可视化三分钟入门,半小时入魔?

idea 热部署

uni-app - Refused to display ‘xxx‘ in a frame because an ancestor violates the following Content Sec

Common tool classes under JUC package

MongoDB数据库文件的读与写

sqli-labs Basic Challenges Less11-22

初始Flask以及简单地上手应用
随机推荐
In mysql, update and select are used together
抽象类和接口的区别(最详细)
Druid 查询超时配置的探究 → DataSource 和 JdbcTemplate 的 queryTimeout 到底谁生效?
MySQL排序
activemq--可持久化机制之JDBC代码
Silicon Valley classroom lesson 15 - Tencent cloud deployment
c语言中的六个存储类型:auto register static extern const volatile
What is the difference between mongodb and redis
Jspdf generates PDF files. There is a problem of incomplete files. Files are downloaded in the background, but not in the foreground
leetcode-238.除自身以外数组的乘积
[SCADA case] myscada helps VIB company realize the modernization and upgrading of production line
activemq--异步投递
redis操作利用游标代替keys
&lt;T&gt;泛型方法演示
@Scheduled源码解析
ActiveMQ -- persistent mechanism
Ranking of data results in MySQL
Publish Yum private server using nexus3 (offline intranet)
Redis-哨兵,主从部署详细篇
activemq--可持久化机制