Codeforces Round #524 (Div. 2)

Posted zgqblogs

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #524 (Div. 2)相关的知识,希望对你有一定的参考价值。

好不容易考完电路,又可以回来刷题了,只是现在恐怕码力连新生都比不上了。

A

开头就是一大水题,意思就是制作一张贺卡需要几张什么颜色的纸,一共做n份,一叠纸有k张纸,问你需要几叠纸。

技术分享图片
1 #include<iostream>
2 #include<cmath>
3 using namespace std;
4 int main()
5 {
6     int n,k;
7     scanf("%d%d",&n,&k);
8     printf("%d
",(int)ceil(1.0*n*8/k)+(int)ceil(1.0*n*5/k)+(int)ceil(1.0*n*2/k));
9 }
View Code

B

给你一个数组,-1,2,-3,4.。。。。。,q次询问,求l到r之间的数组和

直接算就可以了。相邻的两个差距为1嘛!

技术分享图片
 1 #include<iostream>
 2 using namespace std;
 3 int main()
 4 {
 5      int T;
 6      scanf("%d",&T);
 7      while(T--){
 8         int l,r;
 9         scanf("%d%d",&l,&r);
10         int flag1,flag2;
11         if(!(l&1)){l--;flag1=l;}
12         else flag1=0;
13         if(r&1){r++;flag2=r;}
14         else flag2=0;
15         printf("%d
",(r-l+1)/2+flag1-flag2);
16      }
17 }
View Code

 

以上是关于Codeforces Round #524 (Div. 2)的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #524 (Div. 2) codeforces 1080A~1080F

Codeforces Round #524 (Div.2)题解

Codeforces Round #524 (Div. 2)

Codeforces Round #524 Div. 2 翻车记

Codeforces Round #524 (Div. 2)(前3题题解)

Codeforces Round #524 (Div. 2) F