当前位置:网站首页>~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 …
边栏推荐
- Day1: 130 questions in three languages
- CDA level1 multi topic selection
- Depth estimation self-monitoring model monodepth2 paper summary and source code analysis [theoretical part]
- 金鱼哥RHCA回忆录:CL210管理存储--对象存储
- 2271. Maximum number of white bricks covered by blanket ●●
- CDA level Ⅰ 2021 new version simulation question 1 (with answers)
- leetcode--四数相加II
- Workplace "digital people" don't eat or sleep 007 work system, can you "roll" them?
- Four methods of importing CSV text files into Excel
- 【目录爆破工具】信息收集阶段:robots.txt、御剑、dirsearch、Dirb、Gobuster
猜你喜欢

leetcode--四数相加II

Digital Twins - cognition

Business analysis report and data visualization report of CDA level1 knowledge point summary

Hyperautomation for the enhancement of automation in industries

手把手教学Yolov7的搭建及实践

DNS resolution error during windows unbutu20 lts apt, WGet installation

Brush questions - Luogu -p1046 Tao Tao picking apples

Leetcode202 --- Happy number

Dr. Berkeley's "machine learning engineering" big truth; AI vice president '2022 ml job market' analysis; Large list of semiconductor start-ups; Large scale video face attribute data set; Cutting edge

swiper 一侧或两侧露出一小部分
随机推荐
Wangeditor rich text editor
Practice of online problem feedback module (13): realize multi parameter paging query list
Arduino code of key state machine for realizing single, double click, long press and other functions with esp32 timed interrupt
2271. 毯子覆盖的最多白色砖块数 ●●
Brush questions - Luogu -p1046 Tao Tao picking apples
Business analysis report and data visualization report of CDA level1 knowledge point summary
飞盘局有多快乐?2022年轻人新潮运动报告
Nodejs link MySQL error: Er_ NOT_ SUPPORTED_ AUTH_ MODEError: ER_ NOT_ SUPPORTED_ AUTH_ MODE
swiper 一侧或两侧露出一小部分
leetcode--四数相加II
Goldfish rhca memoirs: cl210 management storage -- object storage
[force deduction] 1030. Arrange matrix cells in distance order
伯克利博士『机器学习工程』大实话;AI副总裁『2022 ML就业市场』分析;半导体创业公司大列表;大规模视频人脸属性数据集;前沿论文 | ShowMeAI资讯日报
Esp32 connects to Alibaba cloud mqtt IOT platform
职场「数字人」不吃不睡007工作制,你「卷」得过它们吗?
[original] nine point calibration tool for robot head camera calibration
Mongodb source code deployment and configuration
What financial products can I invest with some money in my hand?
数字孪生 - 认知篇
Deep understanding of pytorch distributed parallel processing tool DDP -- starting from bugs in engineering practice