思维/构造 HDOJ 5353 Average】的更多相关文章

题目传送门 /* 思维/构造:赛后补的,当时觉得3题可以交差了,没想到这题也是可以做的.一看到这题就想到了UVA_11300(求最小交换数) 这题是简化版,只要判断行不行和行的方案就可以了,做法是枚举x[1],x[n]的所有可能,x[2~n-1]能递推出来 x[i]表示i给i+1的值(0/-1/1) 那么 a[i] - x[i] + x[i-1] == ave,详细看代码 */ /************************************************ * Author…
pid=4671">http://acm.hdu.edu.cn/showproblem.php? pid=4671 Problem Description Makomuno has N servers and M databases. All databases are synchronized among all servers and each database has a ordered list denotes the priority of servers to access.…
Description Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresp…
题意: 让你构造一个图,使得A,B,C,D的个数为给定的个数,上下左右连通的算一个. 哎呀 看看代码就懂了..emm..很好懂的 #include <bits/stdc++.h> using namespace std; , INF = 0x7fffffff; ][]; int main() { ; i<; i++) ; j<; j++) ) str[i][j] = 'A'; else str[i][j] = 'B'; int a, b, c, d; cin>> a &…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5353 题意:有n个人围城一个环,每一个人手里都有一些糖果,第i个人有ai块.现在有三种操作:第i个人给第i+1个人一块.第i+1个人给第i个人一块.什么都不做.第i个人和第i+1个人之间,可以选择一种操作并执行,问最终能不能让所有人手里的糖相等. 解法:贪心. 当n = 1 时,永远是YES 当n = 2 时,注意1和2之间只能有一种操作,不存在循环. 当n > 2 时: 糖的总数不能均分到n个人手…
Average Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2069    Accepted Submission(s): 517Special Judge Problem Description There are n soda sitting around a round table. soda are numbered fr…
#include<bits/stdc++.h>using namespace std;const int N=1e6+6;int x[N],y[N];int sx,sy,n;char s[N];bool check(int m){    for(int i=1;i<=n-m+1;i++)    {        int tx=x[n]-x[i+m-1]+x[i-1];  //当前原来选项造成的横坐标影响        int ty=y[n]-y[i+m-1]+y[i-1];  //当前原…
题目传送门 题意:给一棵树,问f (u, v) 意思是u到v的所有路径的边权值的异或和,问f (u, v) == s 的u,v有几对 异或+构造:首先计算f (1, u) 的值,那么f (u, v) == f (1, u) ^ f (1, v),f (u, v) == s -> f (1, u) == s ^ f (1, v), 异或的性质,再考虑s == 0特殊情况就好了 ;;; ; ; ; );        ; ;            ; ) ;                ;    …
题目传送门 题意:给两个字符串s,t,可以在s字符串任意位置后面插入字符c(与前面的不同),问是否能够将s转换为t字符串 构造:首先lens > lent 或者 s[1] != t[1] 一定是No,然后t最前面相同字符长度的部分在s中要相同,否则不能插入,之后的部分只要相同的部分全部存在,不同的部分可以随便插 ;;);    );    ; ; );        ;}…
题目传送门 题意:问有多少个区间,其中存在j使得ai + d1 == ai+1(i<j) && ai + d2 == ai+1 (i>j) 构造:用c1[i], c2[i]记录i为标杆左边最多几个符合以及右边最多几个符合,那么i的贡献为(c1[i]+1) * (c2[i] + 1):当d1==d2时,找出符合的连续区间,长度记为cnt,那么贡献为(cnt+1) * cnt / 2. ;;) ; ; ;        ; ;        ;        ;          …