【BZOJ】1754: [Usaco2005 qua]Bull Math】的更多相关文章

[算法]高精度乘法 #include<cstdio> #include<algorithm> #include<cstring> using namespace std; ; char s1[maxn],s2[maxn]; int a[maxn],b[maxn],c[maxn],lena,lenb,lenc; int main(){ scanf("%s%s",s1,s2); lena=strlen(s1);lenb=strlen(s2); ;i<…
1754: [Usaco2005 qua]Bull Math Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 398  Solved: 242[Submit][Status][Discuss] Description Bulls are so much better at math than the cows. They can multiply huge integers together and get perfectly precise answ…
高精乘法板子 然而WA了两次也是没救了 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int N=105; int la,lb,lc,a[N],b[N],c[N],tot; char ch[N]; int main() { scanf("%s",ch+1); la=strlen(ch+1); for(int i=1;i<=la;i…
Description Bulls are so much better at math than the cows. They can multiply huge integers together and get perfectly precise answers ... or so they say. Farmer John wonders if their answers are correct. Help him check the bulls' answers. Read in tw…
1754: [Usaco2005 qua]Bull Math Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 374  Solved: 227[Submit][Status] Description Bulls are so much better at math than the cows. They can multiply huge integers together and get perfectly precise answers ... o…
[题意]给定n*n网格,有k个物品,每次可以消灭一行或一列,求消灭掉所有物品的最少操作次数. [算法]二分图最小覆盖 [题解]此题是最小覆盖模型的出处. 将物品的x-y连边建立二分图. 最小覆盖:选择最少的点,使每条边至少有一个端点被覆盖. 刚好对应题意. 最小覆盖可以用最小割解决,将选择点视为割去边,S-T不连通就是边至少一个点被覆盖. 注意:二分图开双倍点. #include<cstdio> #include<algorithm> #include<cstring>…
[题意]给定按编号顺序站成一排的牛,给定一些约束条件如两牛距离不小于或不大于某个值,求1和n的最大距离.无解输出-1,无穷解输出-2. [算法]差分约束+最短路 [题解]图中有三个约束条件,依次分析: ①坐标顺序和编号顺序一致[一定一定要记得这个约束条件] xi-xi-1>=0 i向-1连边0 ②两牛距离不大于距离L xj-xi<=L i向j连边L ③两牛距离不小于距离D xj-xi>=D即xi-xj<=-D j向i连边-D 连边完毕,通过跑最短路得到起点和终点的直接约束xT-xS…
http://www.lydsy.com/JudgeOnline/problem.php?id=1675 一开始我写了个枚举7个点....... 但是貌似... 写挫了. 然后我就写dfs.. 判重好难写啊. .... 本来用hash的.. 但是对拍一直wa.. 所以干脆用set.. 然后将数值调大.. 然后就过了.. 然后bzoj数据弱.. 自己对拍还是hash有冲突的.. #include <cstdio> #include <cstring> #include <cma…
http://www.lydsy.com/JudgeOnline/problem.php?id=1673 bzoj翻译过来的c<=230不忍吐槽................................. 这题很奇葩.. 因为这些数像fib数一样递增,所以n<=45...................... ... dfs背包即可... #include <cstdio> #include <cstring> #include <cmath> #in…
http://www.lydsy.com/JudgeOnline/problem.php?id=1677 完全背包很容易想到,将1,2,4...等作为物品容量即可. 然后这题还有一个递推式 f[i]==f[i-1], 当i%2==1 f[i]==f[i-1]+f[i/2], 当i%2==0 当i为奇数时,我们可以看为i-1加上一个1的情况,那么只有f[i-1]中情况(因为每种情况只是多了一个1) 当i为偶数时,分为2种情况,含有1和不含有1,当含有1时,那么情况就是f[i-1],当不含有1时,情…