Content 有 \(t\) 次询问,每次询问给定两个整数 \(l,r\),求 \(\sum\limits_{i=l}^r (-1)^i\times i\). 数据范围:\(1\leqslant t\leqslant 10^3,1\leqslant l\leqslant r\leqslant 10^9\). Solution 建议先去做 CF486A,然后我们可以得知 \(\sum\limits_{i=1}^n (-1)^i\times i=\begin{cases}\dfrac{i}{2}&…
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…
Little girl Margarita is a big fan of competitive programming. She especially loves problems about arrays and queries on them. Recently, she was presented with an array aa of the size of 109109 elements that is filled as follows: a1=−1a2=2a3=−3a4=4a5…
题解 CF1080A [Petya and Origami] 这道题其实要我们求的就是 \[\lceil 2*n/k \rceil + \lceil 5*n/k \rceil + \lceil 8*n/k \rceil\] 然后就做完了 # include <bits/stdc++.h> # define ll long long int main() { ll n, k; scanf("%lld%lld", &n, &k); ll ans = ((2 *…
这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:https://codeforces.com/contest/1080. A.Petya and Origami 题意:Petya要发出n张邀请函,每张请函需要2张红纸,5张绿纸,8张蓝纸.现在商店里有一些不同颜色的笔记本,每本中有k张颜色相同的纸,求最少要买几本笔记本. 这题就是一道模拟题,算出每种…
(A) Even Subset Sum Problem 题解:因为n非常非常小,直接暴力枚举所有区间即可. #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef double db; int t,l,r,n,a[110],s[110]; int main(){ cin>>t; while(t--){ cin>>…
A. Petya and Origamitime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya is having a party soon, and he has decided to invite his n friends. He wants to make invitations in the form of origami. Fo…
A. Petya and Origami time limit per test  1 second   memory limit per test  256 megabytes input standard input output standard output Petya is having a party soon, and he has decided to invite his nn friends. He wants to make invitations in the form…
A. Petya and Origami Water. #include <bits/stdc++.h> using namespace std; #define ll long long ll n, k; ll Get(ll x) { ? (x * n) / k : (x * n) / k + ; } int main() { while (scanf("%lld%lld", &n, &k) != EOF) { ll res = Get() + Get()…
说起来这还是本蒟蒻学完Floyd之后做的第一道题. emm...这是一道裸题,题目大致是说有一堆岛,岛之间有海盗,因此每一条边都有一个危险指数(权重),然后给出一段必须经过的路线,求从一号小岛走到N号小岛最小的危险指数是多少. 先介绍一下Floyd算法吧: Floyd(弗洛伊德)算法是用来求解带权图(无论正负)中的多源最短路问题.算法的原理是动态规划. 用dist(i,j,k)表示从顶点i到顶点j只经过前k个顶点的最短路的长度.那么只有如下两种情况 1.i,j之间的最短路不经过k+1,dist(…