摘要:题目链接K-th NumberTime Limit:20000MSMemory Limit:65536KTotal Submissions:36890Accepted:11860Case Time Limit:2000MSDescriptionYou are working for Macrohar...
阅读全文
摘要:题目链接食物链Time Limit:1000MSMemory Limit:10000KTotal Submissions:44316Accepted:12934Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。现有N个动物,以1-N编...
阅读全文
摘要:关于单调栈的性质,和单调队列基本相同,只不过单调栈只使用数组的尾部, 类似于栈。Accepted Code: 1 /************************************************************************* 2 > File Name:...
阅读全文
摘要:开关问题Time Limit:1000MSMemory Limit:30000KTotal Submissions:5418Accepted:2022Description有N个相同的开关,每个开关都与某些开关有着联系,每当你打开或者关闭某个开关的时候,其他的与此开关相关联的开关也会相应地发生变化,...
阅读全文
摘要:排列组合: poj1850, poj3252• Lucas 定理: poj3219• 素数测试与筛法: poj2191, poj1811• 大数分解的快速算法: poj1142• 进位制: poj2798, poj1702• 同余模运算: poj1006, poj2115• 容斥原理: poj39...
阅读全文
摘要:NetworkTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 8403Accepted: 3930DescriptionA Telephone Line Company (TLC) is establishing a new tele...
阅读全文
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 6 int sg[205][205]; 7 8 int solve(int w,int h){ 9 if(sg[w][h]!=-1){10 return ...
阅读全文
摘要:1 #include 2 #include 3 4 typedef long long ll; 5 6 void gcd(ll a,ll b,ll& d,ll& x,ll& y){ 7 if(b==0){ 8 d=a; x=1; y=0; return ; 9 ...
阅读全文
摘要:做了这题,才知道剪枝的厉害。。。正要的剪枝:如果当前木棍能恰好填满一根原始木棍,但因剩余的木棍无法组合出合法解而返回,那么让我们考虑接下来的两种策略,一是用更长的木棍来代替当前木棍,显然这样总长度会超过原始木棍的长度,违法。二是用更短的木棍组合来代替这根木棍,他们的总长恰好是当前木棍的长度,但是由于...
阅读全文
摘要:1 #include 2 #include 3 #define max 32 4 5 typedef long long LL; 6 LL pow2[max+5]; 7 8 void init(){ 9 for(int i=1;i<=max;i++){10 pow2[i...
阅读全文
摘要:题目链接: http://poj.org/problem?id=2109代码很简单,但是还是学到了东西。。类型 长度 (bit) 有效数字 绝对值范围float 32 6~7 10^(-37) ~ 10^38double 64 15~16 10^(-307) ~10^308long double ...
阅读全文
摘要:1 #include 2 #include 3 #define INF 999999999 4 #define Min(x,y) (x<y?x:y) 5 #define max 300+5 6 //dp[i][k]记录在从1到i的村庄中放置k个邮局的最短总距离 7 //sum[i][j]记录在从第...
阅读全文
摘要:1 /*第一道离散化的题目,虽然是水题,不过还是很高兴。。。*/ 2 3 #include 4 #include 5 #include 6 using namespace std; 7 struct rect 8 { 9 double x1,x2,y1,y2;10 };11 #define m...
阅读全文
摘要:#include#define max 1000000+5int a[max],q1[max]/*单调递增*/,q2[max]/*单调递减*/,ans1[max],ans2[max];int n,k,h1,t1,h2,t2;void q1_in(int i){ //入队 while(h1=a[i]...
阅读全文