摘要: 题目链接暴力枚举,a+b+a*b = N,(a+1)*(b+1) = N+1,10^5枚举起来吧。。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <math.h> 5 #define N 1000000000 6 int main() 7 { 8 int i,t,k,num; 9 __int64 n;10 scanf("%d",&t);11 while(t--)12 {13 scanf("%I64d& 阅读全文
posted @ 2012-08-23 20:50 Naix_x 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 题目链接一开始那个初始化错了,WA了N次啊。。。Vijos上数据太水了,POJ上本来也想水过的,这个感觉将近O(n^4)的复杂度,交上超时了,本来想优化一下预处理出前i个和的,发现好像这个复杂度,找最小的时候,没法优化。。看了DISCUSS,有人就这样水过的,把INT64啥的,小细节改改成了750ms。。。四边形不等式优化,纠结。。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #define N 1000000000 5 int p[301]; 6 int dp[31 阅读全文
posted @ 2012-08-23 20:22 Naix_x 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 题目链接有结论。。在有向图中,每两个点都存在一条边,如果存在环,则一定存在3元环。拓扑排序一下。 1 #include <stdio.h> 2 #include <string.h> 3 char str[2001][2001]; 4 int o1[2001],o2[2001],k[2001]; 5 int main() 6 { 7 int t,i,j,num = 0,n,z,nu; 8 scanf("%d",&t); 9 while(t--)10 {11 num ++;12 memset(k,0,sizeof(k));13 ... 阅读全文
posted @ 2012-08-23 11:49 Naix_x 阅读(164) 评论(0) 推荐(0) 编辑