Codeforces Round #524 (Div. 2) B. Margarite and the best present
B. Margarite and the best present
题目链接:https://codeforces.com/contest/1080/problem/B
题意:
给出一个数列:an=(-1)n,之后有询问,问 [l,r] 之间的ai和为多少。
题解:
这个分情况讨论一下就可以了,区间长度的奇偶数丶左端点的奇偶数。
代码如下:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std; typedef long long ll;
int q;
int main(){
cin>>q;
for(int i=;i<=q;i++){
int l,r;
scanf("%d%d",&l,&r);
int len = r-l+;
if(len%){
if(l%) printf("%d\n",len/+r);
else printf("%d\n",r-len/);
}else{
if(l%) printf("%d\n",len/);
else printf("%d\n",-len/);
}
}
}
Codeforces Round #524 (Div. 2) B. Margarite and the best present的更多相关文章
- Codeforces Round #524 (Div. 2)(前三题题解)
这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:h ...
- Codeforces Round #524 (Div. 2)
A. Petya and Origamitime limit per test1 secondmemory limit per test256 megabytesinputstandard input ...
- Codeforces Round #524 (Div. 2) Solution
A. Petya and Origami Water. #include <bits/stdc++.h> using namespace std; #define ll long long ...
- Codeforces Round #524 (Div.2)题解
题解 CF1080A [Petya and Origami] 这道题其实要我们求的就是 \[\lceil 2*n/k \rceil + \lceil 5*n/k \rceil + \lceil 8*n ...
- Codeforces Round #524 (Div. 2) F. Katya and Segments Sets(主席树)
https://codeforces.com/contest/1080/problem/F 题意 有k个区间,区间的种类有n种,有m个询问(n,m<=1e5,k<=3e5),每次询问a,b ...
- Codeforces Round #524 (Div. 2) E. Sonya and Matrix Beauty(字符串哈希,马拉车)
https://codeforces.com/contest/1080/problem/E 题意 有一个n*m(<=250)的字符矩阵,对于每个子矩阵的每一行可以任意交换字符的顺序,使得每一行每 ...
- Codeforces Round #524 (Div. 2) C. Masha and two friends(矩形相交)
C. Masha and two friends time limit per test 1 second memory limit per test 256 megabytes input stan ...
- Codeforces Round #524 (Div. 2) D. Olya and magical square
D. Olya and magical square 题目链接:https://codeforces.com/contest/1080/problem/D 题意: 给出一个边长为2n的正方形,每次可以 ...
- Codeforces Round #524 (Div. 2) codeforces 1080A~1080F
目录 codeforces1080A codeforces 1080B codeforces 1080C codeforces 1080D codeforces 1080E codeforces 10 ...
随机推荐
- python-time模块、sys模块、os模块以及大量实例
模块 通俗的说模块就把一个已经写好的带有可使用的函数的文件,通过文件名进行导入,然后调用里面的函数等来完成所需功能,模块封装了你需要实现功能的代码,使用者只需调用即可,简化代码量,缩短编程时间. ti ...
- Go语言使用百度翻译api
Go语言使用百度翻译api 之前做过一个使用百度翻译api的工具,这个工具用于用户的自动翻译功能,是使用C#调用百度翻译api接口,既然在学习Go语言,那必然也是要使用Go来玩耍一番.这里我是这么安排 ...
- HyperLedger Fabric 1.4 超级账本组织(5.3)
超级账本组织分为TSC(技术指导委员会).Governing Board(董事会成员).LF Staffs(工作人员)三个组织,组织架构图如下: TSC:技术指导委会员,主导社区的开发工作,下设多个工 ...
- 【EXCEL】SUMIFS(複数の条件を指定して数値を合計する)
分享:
- java 第五章 方法定义及调用
1.方法的定义 什么是方法 方法是完成某个功能的一组语句,通常将常用的功能写成一个方法 方法的定义 [访问控制符] [修饰符] 返回值类型 方法名( (参数类型 形式参数, ,参数类型 形式参数, , ...
- Linux - 信息收集
1. #!,代表加载器(解释器)的路径,如: #!/bin/bash echo "Hello Boy!" 上面的意思是说,把下面的字符(#!/bin/bash以下的所有字符)统统传 ...
- Prolog奇怪奇妙的思考方式
今天在<七周七语言>中接触到了prolog,发现它的编程模式和思考方式的确比较奇怪,但同时也非常奇妙,值得学习一下. 1. prolog语言介绍 和SQL一样,Prolog基于数据 ...
- Python 3基础教程23-多维列表
这里简单举例一个多维列表,多维看起来都很晕. # 多维列表 x = [ [5,6],[6,7],[7,2] ,[2,5] ,[4,9]] print(x) # 根据索引引用列表元素,例如打印[6,7] ...
- [P2387魔法森林
题面 题意: 给出一个图,边权有两维,a与b. 求1到n的一条路径使得路径经过的边的最大的a与b的和最小,输出最小之和. \(Solution:\) 如果做过这题,那么就显得很简单了很好想了. 又是想 ...
- 1066 Root of AVL Tree (25 分)(平衡二叉树)
就是AVL的模板题了 注意细节 #include<bits/stdc++.h> using namespace std; typedef struct node; typedef node ...