01 2016 档案
摘要:模板题。 #include <cstdio> #include <cstring> using namespace std; const int MOD = 10000; int N; struct matrix { int m[2][2]; }ans,base; matrix multi(matr
阅读全文
摘要:FJ对以后的每一天会花mi块钱,他想把这些天分成M个时段,然后每个时段的花费和最小。 二分答案,如果加上这天还没有达到mid,就加上它。之后看分成的时段是否大于M #include <cstdio> #include <algorithm> using namespace std; int n,m,
阅读全文
摘要:一条河里有一串石头,给出石头间的间距,让你去掉m个石头,使最短间距最大。 二分答案,对于每一种mid,判断要不要删除这块石头。然后逼近答案。 #include <cstdio> #include <cstring> #include <algorithm> using namespace std;
阅读全文
摘要:一根细棒升温时会变长,在两面墙中间,会变成一个弓形。 给出变长后的长度,求新的细棒中心与没伸长时的中心的距离。 简单的数学推导后就可以二分答案了,一开始没完全掌握二分的姿势,wa了好多。而且poj double输出要用%f,用%lf就wa了。 #include <cstdio> #include <
阅读全文
摘要:有N个派,F+1个人,每个人分到的体积要相等,而且每个人只能有一块派。 二分答案,对于一个mid,对每个派进行检测,尽量的多分,然后如果份数比F+1大,说明mid可以更大,就把mid给low。注意份数等于F+1时,也要向大的地方靠近。 二分答案的题都是这样的套路。 这种题精度是一个大坑。总是在wa和
阅读全文
摘要:给出一个数字n,计算从1到n能组成几个不同的三角形。 n的范围是10^6,大概就是递推吧。从F[i-1]到F[i]可以线性求出。要注意结果超出int。 #include <cstdio> #include <cstring> #include <algorithm> using namespace
阅读全文
摘要:计算一个大整数(10^100)中有没有一个小于L的素因子。这个大整数是两个素数的乘积。其实就是RSA加密。 做法是把大整数表示成千进位,用数组存储,然后一位一位地取模。 /*---------------------------------------------------------------
阅读全文
摘要:线性同余方程的模板题。和青蛙的约会一样。 #include <cstdio> #include <cstring> #define LL long long using namespace std; //A+n*C = B mod 2^k //n*C = B-A mod 2^k LL A,B,C,M
阅读全文
摘要:从n+m步中挑选min(n,m)步向上走,剩下的就是向下走。 求解n+mCmin(n,m)时,要一边计算一边约分。 #include <cstdio> #include <algorithm> #include <iostream> using namespace std; unsigned int
阅读全文
摘要:求出给定序列的序号。有一个定理需要知道 具体看这篇博客吧http://blog.csdn.net/lyy289065406/article/details/6648492 #include <cstdio> #include <cstring> #include <algorithm> using
阅读全文
摘要:1 12 123 1234 把数按照这样的形式拍成一排,给一个序号求出那个序号对应的数。 当出现两位数。三位数时,要麻烦的处理一下。 #include <cstdio> #include <algorithm> #include <cmath> using namespace std; int T,
阅读全文
摘要:614A-Link/Cut Tree 比较水,注意64位int仍然可能溢出。 #include <cstdio> #include <algorithm> #include <cstring> using namespace std; typedef unsigned long long int L
阅读全文
摘要:当一个数的二进制表示中,0的个数大于或等于1的个数时,叫做RoundNumber。求从S到F两个数(包含)之间的RoundNumber个数。 这类题一般都是先求出0到N的个数,然后两个相减。 由于题目是考虑二进制中01的个数,当位数固定时,很方便计算。于是从位数方面解决问题。 设N表示成二进制的位数
阅读全文