摘要: 地址:http://hustoj.sinaapp.com/problem.php?id=1838笨办法先列出所有分母不大于n的真分数,用二维数组储存,然后按分数大小排序输出的时候按顺序来,选gcd(分子, 分母)=1的输出 1 #include <iostream> 2 #include <algorithm> 3 #define MAX 160 4 using namespace std; 5 6 int n; 7 int **f=new int *[MAX*(MAX-1)/2+2]; 8 9 bool cmp(int *a,int *b)10 {11 double 阅读全文
posted @ 2013-01-29 22:30 tjsuhst 阅读(293) 评论(0) 推荐(0) 编辑
摘要: 地址:http://hustoj.sinaapp.com/problem.php?id=1832对于搜索不够敏感,其实与状态有关的,且存在状态改变的,都可以考虑一下搜索这题就是DFS给出A,B,C三个桶的大小,(0,0,C)——也就是说C桶是满的,从这个状态开始互相倒来倒去,输出A桶为0时,C桶可能的牛奶量 1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 5 int a,b,c,con; 6 bool s[21][21][21],flag[21]; 7 8 void dfs(in 阅读全文
posted @ 2013-01-29 21:32 tjsuhst 阅读(368) 评论(0) 推荐(0) 编辑
摘要: 地址:http://codeforces.com/contest/268/problem/C给定一个平面0 ≤ x ≤ n;0 ≤ y ≤ m;x + y > 0,在其中寻找一个最大的坐标均为整数的点集,且每两点间的距离不为整数找无理数也可以,三角形可以变成一个线段,只要两段距离为无理数,那么第三个距离也是无理数所以寻找这样的平面内最大的正方形,选择其副对角线上的点输出 1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 5 int n,m; 6 7 int main() 8 阅读全文
posted @ 2013-01-29 17:36 tjsuhst 阅读(334) 评论(0) 推荐(0) 编辑
摘要: 地址:http://codeforces.com/contest/268/problem/B找规律,有公式,累加即可 1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 5 int n,ans; 6 7 int main() 8 { 9 ios::sync_with_stdio(false);10 int i,j;11 cin>>n;12 for(i=n-1,j=1;i>=0 && j<=n;i--,j++)13 {14 if(i==0) an 阅读全文
posted @ 2013-01-29 17:33 tjsuhst 阅读(242) 评论(0) 推荐(0) 编辑
摘要: 地址:http://codeforces.com/contest/268/problem/A枚举的同时计数... 1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 5 int n,h[30],a[30]; 6 7 int main() 8 { 9 ios::sync_with_stdio(false);10 int con=0;11 cin>>n;12 for(int i=0;i<n;i++)13 {14 cin>>h[i]>>a[i];1 阅读全文
posted @ 2013-01-29 17:31 tjsuhst 阅读(145) 评论(0) 推荐(0) 编辑