A. Greed time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Jafar has n cans of cola. Each can is described by two integers: remaining volume of cola ai and can's capacity bi (ai  ≤  bi). Jaf…
题目 papyrus 喜欢谜题... 来解一道如何? 在你面前有一个被加密了的数组,其原数组是一个等差序列,你面前的则是将原数组中的所有数字都对m 取模再打乱后而得到的新数组 papyrus 给你出的谜题就是还原出原等差序列 保证数据有解,而且因为papyrus 喜欢质数,所以他给你出的谜题中的m 一定是质数 分析 将a排序,当a[1]不是末项时,a[i]-a[1]一定有一个为公差 枚举公差d, 我们就可以通过等差数列和来求出首项a1, 我们通过a1和d来求出对应的等差数列平方和,na1²+n(…
Valya and Tolya are an ideal pair, but they quarrel sometimes. Recently, Valya took offense at her boyfriend because he came to her in t-shirt with lettering that differs from lettering on her pullover. Now she doesn't want to see him and Tolya is se…
A. Taymyr is calling you time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinis…
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0,那么这个点就是水龙头点. 如果这个点的出度为0,那么这个点就是储存点. 现在让你把所有水龙头到储存点的路径都输出出来,且输出这条路径的边权最小值 题解 显然是个仙人掌图,所以直接XJB暴力就好了 代码 #include<bits/stdc++.h> using namespace std; co…
A. Rounding time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with 0, V…
A. Games time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice diffe…
B. Wrath time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Hands that shed innocent blood! There are n guilty people in a line, the i-th of them holds a claw with length Li. The bell rings a…
A. QAQ time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output "QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth. Now Dia…
D. Flowers time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input output standard output We saw the little game Marmot made for Mole's lunch. Now it's Marmot's dinner time and, as we all know, Marmot eats flowers. At…
[链接] 我是链接,点我呀:) [题意] [题解] 找到度数为1的点. 他们显然是叶子节点. 然后每个叶子节点. 往上进行bfs. 累计他们的父亲节点的儿子的个数. 如果都满足要求那么就继续往上走. 直到不能走.或已经走了k步. 且要求走了k步之后.他们都到了同一个节点.(根节点 这道题. n=1的时候,认为是无解的. (因为题目中说"some vertices of degree 1",也就是说必须>= 1....... [代码] /* find each vertex i w…
A. Counterexample time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Your friend has recently learned about coprime numbers. A pair of numbers {a, b} is called coprime if the maximum number th…
A. Cakeminator time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a rectangular cake, represented as an r × c grid. Each cell either has an evil strawberry, or is empty. For exam…
A. Arya and Bran time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies…
D. Restoration of string time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A substring of some string is called the most frequent, if the number of its occurrences is not less than number of…
A. Hungry Student Problem time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some frie…
D题: 题目思路:给你n个不想交的矩形并别边长为奇数(很有用)问你可以可以只用四种颜色给n个矩形染色使得相接触的 矩形的颜色不相同,我们首先考虑可不可能,我们分析下最多有几个矩形互相接触,两个时可以都互相接触 三个时也可以互相接触,而四个时怎么摆我们都不能让他们相互都接触,所以我们最多可以用三种不同颜色 的矩形去接触另一个矩形,因此我们就一定可以用四种颜色来染色,然后我们来考虑怎么染色,因为不存在相 交的情况,所以就拿左下角来分析,首先我们来分析下, 1,两个矩形要上下接触时:我们考虑纵坐标,因…
标题写的树形DP是瞎扯的. 先把1看作根. 预处理出f[i]表示以i为根的子树是什么颜色,如果是杂色的话,就是0. 然后从根节点开始转移,转移到某个子节点时,如果其子节点都是纯色,并且它上面的那一坨结点也是纯色,就输出解. 否则如果其上面的一坨是纯色,并且其子节点有且只有一个杂色的时候,就递归处理该子节点. #include<cstdio> #include<cstdlib> using namespace std; #define N 100050 int v[N<<…
任意门:http://codeforces.com/contest/1066/problem/B B. Heaters time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vova's house is an array consisting of nn elements (yeah, this is the first probl…
A. Taymyr is calling you time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinis…
CF比赛题目地址:http://codeforces.com/contest/862 A. Mahmoud and Ehab and the MEX ·英文题,述大意:      输入n,x(n,x<=100),然后输入n个数作为一个集合.现在可以进行多次操作,每次操作为删除一个数或者添加一个数,求最少操作数使得集合Mex值等于x. ·分析:      也许是考察Mex的吧~那就当复习了,我们的策略是,如果当前集合的  Mex比x小,那就一直添加数;如果Mex比x大,那么就删除那个和x相同的元素…
地址:http://codeforces.com/contest/764/problem/D 题目: D. Timofey and rectangles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One of Timofey's birthday presents is a colourbook in a shape o…
地址:http://codeforces.com/contest/764/problem/C 题目: C. Timofey and a tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Each New Year Timofey and his friends cut down a tree of n vertices…
地址:http://codeforces.com/contest/764/problem/B 题目: B. Timofey and cubes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Young Timofey has a birthday today! He got kit of n cubes as a birthd…
比赛链接:http://codeforces.com/contest/763 A题: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; ; ],son[N<<],c[N],a[N]; void read(int &x){ x=; ; char ch…
主题链接:http://codeforces.com/contest/433/problem/B 题目大意:给n(1 ≤ n ≤ 105)个数据(1 ≤ vi ≤ 109),当中有m(1 ≤ m ≤ 105)个问题,分两种.第一种:给出l,r,让你求出v[l],v[r]之间的全部数据和:另外一种:先将原数据升序排序得到vv数组,给出l,r,让你求出vv[l],vv[r]之间的全部数据和: 此题假设用暴力求解,因为数据太大,会TLE,所以利用树状数组,高速求解区间和的问题. 假设不懂树状数组,能够…
D1:思路:L,R指针移动,每次选最小的即可. #include<bits/stdc++.h> using namespace std; #define int long long #define N 200009 int arr[N]; int ans[N]; signed main(){ int n; cin>>n; ;i<=n;i++){ cin>>arr[i]; } ,r=n; ; ; ){ if(now<arr[l]&&now<…
B. Nikita and string One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st…
C. White Sheet There is a white sheet of paper lying on a rectangle table. The sheet is a rectangle with its sides parallel to the sides of the table. If you will take a look from above and assume that the bottom left corner of the table has coordina…
简易字符串匹配,题意不难 #include <stdio.h> #include <string.h> #include <math.h> #include <iostream> #include <algorithm> using namespace std; int main(){ int i, j, k, t, n; int num, flag, ans; ]; scanf("%s",a); scanf("%d…