摘要: 地址:http://hustoj.sinaapp.com/problem.php?id=1839将乱序的数列中的元素两两交换,变成升序数列,输出所需最小步骤数其实就是模拟一个过程,只有三种数,先是找只需交换一次便归位的,然后是交换两次三个数归位的,交换时计数就行 1 #include <iostream> 2 #include <algorithm> 3 #include <vector> 4 5 using namespace std; 6 vector<int> num,con(4); 7 int n,con_num; 8 9 void sw 阅读全文
posted @ 2013-03-09 19:08 tjsuhst 阅读(318) 评论(0) 推荐(0) 编辑
摘要: 地址:http://codeforces.com/contest/270/problem/D这题看过别人代码,理解了好久本来觉得这题和USACO里的三值的排序是一样的,但是USACO里通不过......看来还得想 1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 5 int n,m,s[5001],p[5001]; 6 double x; 7 8 int main() 9 {10 ios::sync_with_stdio(false);11 int j;12 cin>> 阅读全文
posted @ 2013-02-10 21:19 tjsuhst 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 地址:http://codeforces.com/contest/270/problem/C边读边算,算出当前所需最小箱子,每次结果进行对比,找最大 1 #include <iostream> 2 using namespace std; 3 4 int n,k,a; 5 6 int main() 7 { 8 ios::sync_with_stdio(false); 9 cin>>n;10 int ans=0;11 for(int i=0;i<n;i++)12 {13 cin>>k>>a;14 if(1==a) k++... 阅读全文
posted @ 2013-02-02 21:44 tjsuhst 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 地址:http://codeforces.com/contest/270/problem/B更新的数字会上浮,从后往前找降序子串,这就是没有更新的,从而得到更新的数量 1 #include <iostream> 2 using namespace std; 3 4 int n,a[100000]; 5 6 int main() 7 { 8 ios::sync_with_stdio(false); 9 int con=1;10 cin>>n;11 for(int i=0;i<n;i++)12 {13 cin>>a[i];14 }... 阅读全文
posted @ 2013-02-02 21:42 tjsuhst 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 地址:http://codeforces.com/contest/270/problem/A用多边形外角来做,外角和为360度,然后比对边数 1 #include <iostream> 2 using namespace std; 3 4 int t,a; 5 6 int main() 7 { 8 ios::sync_with_stdio(false); 9 cin>>t;10 while(t--)11 {12 cin>>a;13 int n;14 n=360/(180-a);15 int su... 阅读全文
posted @ 2013-02-02 21:20 tjsuhst 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 地址: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 阅读(292) 评论(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 阅读(240) 评论(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) 编辑