水题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; struct X { int x,y; }s[],tmp[]; int n; int main() { scanf("%d",&n); ;i<=n;i++) scanf("%d%d",&s[i].x,&…
A. Wilbur and Swimming Pool Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/problem/A Description After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his back…
A. Wilbur and Swimming Pool time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in…
C time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his backyard. He has set u…
 A - Wilbur and Swimming Pool Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 596A Description After making bad dives into swimming pools, Wilbur…
Description After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his backyard. He has set up coordinate axes, and he wants the sides of the rectangle to be parallel to them. Of course, the a…
Description After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his backyard. He has set up coordinate axes, and he wants the sides of the rectangle to be parallel to them. Of course, the a…
http://codeforces.com/problemset/problem/735/C 题意:有n个人打锦标赛,淘汰赛制度,即一个人和另一个人打,输的一方出局.问这n个人里面冠军最多能赢多少场,其中一个人和另一个人能打比赛当且仅当这两个人赢的局数相差不超过1. 思路:比赛的时候不会做..直接log2(n)交,果断错了.看题解:因为限制条件两个人能比赛当且仅当他们赢得局数相差不超过1,设F[x]为冠军赢x盘的时候需要的总人数,那么有这样的递推式:F[x] = F[x-1] + F[x-2].…
D. Spongebob and Squares Spongebob is already tired trying to reason his weird actions and calculations, so he simply asked you to find all pairs of n and m, such that there are exactly x distinct squares in the table consisting of n rows and m colum…
Problem D"Decoding Task" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100002 Description In the near future any research and publications about cryptography are outlawed throughout the world on the grounds of national se…
http://codeforces.com/contest/596/problem/D 题目大意: 有n棵树排成一排,高度都为h. 主人公要去砍树,每次等概率地随机选择没倒的树中最左边的树或者最右边的树把它砍倒.每棵树被砍到后,有p的概率会往左边倒,(1-p)的概率往右边倒. 树倒下后如果压到别的树,即如果那棵树倒下的方向上距离不到h的地方还有一棵树,,那么那棵树也会朝和这个树相同的方向倒下. 问最后所有的树都被砍完后覆盖的地面的长度的期望. 思路:dp[i][j][0/1][0/1]代表i到j…
http://codeforces.com/contest/716/problem/C 题目大意:感觉这道题还是好懂得吧. 思路:不断的通过列式子的出来了.首先我们定义level=i, uplevel = i + 1,目前的uplevel,然后我们可以知道,之前求出来的restgrade%level = 0,于是我们可以列出一个式子sqrt(k1 * i + grade) = uplevel * k.因为grade也是i的倍数,假定grade = k2 * i,所以我们写成sqrt((k1 +…
D. Winter is here time limit per test:3 seconds memory limit per test:256 megabytes input:standard input output:standard output Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n soldiers. While the res…
A continued fraction of height n is a fraction of form . You are given two rational numbers, one is represented as  and the other one is represented as a finite fraction of height n. Check if they are equal. Input The first line contains two space-se…
https://vjudge.net/problem/48715/origin 题意:给出必定含1689四个数字的字符串,随意交换位置构造出能被7整除的数. 分析:数学思维题.观察发现1689的排列与7的余数恰好是0...6,那么利用这个性质去与串中其他数字相补出能被7整除的数,把1689固定在后四位,把0独自提取出来,其他数字为一组,把它们的数值*10000后mod7,根据得到的余数选择相应的1689排列,最后把0放在末尾(对结果正确性没有影响).代码: #include <cstdio>…
首先可以把 i mod n=j mod n的看成是同一类,i mod s=j mod s的也看成是同一类,也就是i mod gcd(s,n)的是同一类,很好理解,但是不会数学证明...大概可以想成数轴上一点可以向左向右跳s或n,根据错位相消能互达的两点最小距离为gcd(s,n),所以如果选择点i必须满足a(i)>=a(i+k*gcd(s, n)). 于是可以枚举d表示gcd(s, n),处理出所有可以被选择的点,1表示可选,0表示不可选,组成一个01序列,倍增一次后求出f[i]表示每一个点出发最…
题目: Little C loves number «3» very much. He loves all things about it. Now he has a positive integer nn. He wants to split nn into 3 positive integers a,b,ca,b,c, such that a+b+c=na+b+c=n and none of the 3 integers is a multiple of 3. Help him to fin…
题目链接:http://codeforces.com/problemset/problem/402/D 题意: 给你一个长度为n的数列a[i],又给出了m个“坏质数”b[i]. 定义函数f(s),其中p是s的最小质因子: f(1) = 0 f(s) = f(s/p) + 1 (p不是坏质数) f(s) = f(s/p) - 1 (p是坏质数) 你可以任意次数地进行操作:给a[1 to i]的每个数都除以gcd(a[1 to i]). 问你 ∑ f(a[i)最大为多少. 题解: 函数f(s)的实际…
题目链接:http://codeforces.com/contest/876/problem/B 题意: 给你n个数a[i],让你找出一个大小为k的集合,使得集合中的数两两之差为m的倍数. 若有多解,输出任意一个集合即可. 题解: 若一个集合中的数,两两之差为m的倍数,则他们 mod m 的值均相等. 所以O(N)扫一遍,对于每个数a:vector v[a%m].push_back(a) 一旦有一个集合大小为k,则输出. AC Code: #include <iostream> #includ…
题目链接: http://codeforces.com/contest/658/problem/D 题意: 给定合法多项式,改变一项的系数,使得P(2)=0,问有多少种方法? 分析: 暴力求和然后依次试一试肯定不行啦~ 仔细想想,多项式和为0,就是说存在某个2i,使得剩下的和等于x∗2i,(其中x 的绝对值小于等于k). 那我们就从最小的开始看.把系数依次向后移. 如果系数ai为偶数,那么ai∗2i=(ai/2)∗2i+1,就令bi=0,否则bi=1,最终所有系数都移到了2n上. 如果某个bi为…
题目链接:http://codeforces.com/problemset/problem/509/D 题意:题目给出公式w[i][j]= (a[i] + b[j])% k; 给出w,要求是否存在这样的数列,若存在则求出a,b 和k 题解:如果有符合条件的点的话那么a[i],b[j]可以任意转换比如说a[i],b[j]可以转化为a[i]-p,b[i]+p.所以只要存在 符合条件的解的a[i]可以为任意值.也就是说a[i]可以先赋值为0然后其他就都可以推出来了,当然开始推出后会发现 有负的,没事,…
题目链接:http://codeforces.com/contest/572/problem/C 题意:给出a,b,c,l要求a+x,b+y,c+z构成三角形,x+y+z<=l,成立的x,y,z有多少种 题解:看上去感觉挺复杂的其实就是简单枚举一下就行,首先要知道可以将总的取法减去不满足的取法就可以得到答案, 当然也可以直接枚举可行的方案但是会很复杂.所以最好采用减的方案. 总的方案的求法:就是将l分成3份,显然分法有C(i+2)取(2). 然后再分别减去以a,b,c为最长边不符合条件的种类即可…
https://codeforces.com/contest/1143/problem/D 题意 有nk个城市,第1,k+1,2k+1,...,(n-1)k+1城市有餐厅,你每次能走l距离,a为起始位置离最近餐厅的距离,b为走了一次后离最近餐厅的距离,给出n,k,a,b,求你回到起点最少和最多停留次数 题解 \(yl=xnk,有y=xnk/l,即y=lcm(xnk,l)/l\) 枚举a(两种情况),b(两种情况),维护最大,最小值 代码 #include<bits/stdc++.h> #def…
A. Plus and Square Root time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) an…
题目链接: A. Dreamoon and Sums time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input output standard output Dreamoon loves summing up something for no reason. One day he obtains two integers a and b occasionally. He wan…
题意: 一个袋子里装了n个球,每个球都有编号.甲乙二人从每次随机得从袋子里不放回的取出一个球,如果甲取出的球比乙取出的球编号大则甲胜,否则乙胜.保证球的编号xi各不相同.每轮比赛完了之后把取出的两球放回.求甲在前两轮比赛胜利,乙在最后一轮比赛胜利的情况下,乙所有球的和大于甲所有球的和概率. 其中 2<=n<=2000  1<=xi<=5000 思路: 从xi的范围入手,记录某一轮中两个人的差值,然后再求解出一个后缀和,代表某轮比赛中其中一人比另一人大x以上的概率.这样枚举前两轮的差…
A - Luggage DistributionTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87493#problem/A Description All provident tourists know about low-cost airlines. Those who used them at least once also know th…
一直在考虑, 每一段的贡献, 没想到这个东西能直接dp..因为所有的h都是一样的. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #define PII pair<int, int> #define SZ…
Valera is a coder. Recently he wrote a funny program. The pseudo code for this program is given below: //input: integers x, k, pa = x;for(step = 1; step <= k; step = step + 1){ rnd = [random integer from 1 to 100]; if(rnd <= p) a = a * 2; else a = a…
题意:一个矩阵上面有0~9的数字,可以从任意一个格子出发,每次根据格子上的数字会前进到另一个格子(或原地不动),现在给出q个数位串,问是否有走法可以取出这个串(走到格子上的时候可以不取). 思路:发现每个点的出度至多为1,那么可以预处理出走到这个格子后取某个数字最近的格子是哪个(f[i][j][0-9]),然后用队列存下开头,在做一遍贪心就可以了 #include<cstdio> #include<cmath> #include<cstring> #include<…