摘要: 题意:字符串的操作处理 1 // Problem#: 8768 2 // Submission#: 2606406 3 // The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License 4 // URI: http://creativecommons.org/licenses/by-nc-sa/3.0/ 5 // All Copyright reserved by Informatic Lab of Sun Yat-sen Univers 阅读全文
posted @ 2014-01-09 21:55 shaoshuai1990 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 题意:判断有向图两点之间是否可通达!解法:深搜或广搜(注意避免旧路重行) DFS: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 struct Road{ 7 int From; 8 int Dest; 9 bool Vist;10 Road(int f,int d,bool v){11 From = f;12 Dest = d;13 Vist = v;14 }15 };16 vector roads[20001];17 b... 阅读全文
posted @ 2014-01-09 21:39 shaoshuai1990 阅读(362) 评论(0) 推荐(0) 编辑
摘要: /**** 题意:求x,y 满足 x*pa+y*pb=n 同时使得 p = x*ca+y*cb的值最小,若有多种可能,则选择最大x值的组合** 分析:x*pa+y*pb=n 可以用 线性同余方程 求得各组解: X=x+(pb/q)*t, Y=y-(pa/q)*t **t为整数,显然 X,Y>=0,所以 -x/(pb/q) 0,t应取最小值;**当pb*ca-pa*cb=0,应选择较大的X值,显然 pb/q总是大于0的,所以t 选择最大值,X取得更大值**http://zh.wikipedia.org/wiki/%E6%89%A9%E5%B1%95%E6%AC%A7%E5%87%A0%E9 阅读全文
posted @ 2014-01-08 21:21 shaoshuai1990 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 题意:求满足n! 6 #include 7 using namespace std; 8 int main(){ 9 int year;10 double res;11 while(cin >> year && year >0){12 //add 2 because of the beginning with 4, 1<<2 equals with 4 13 int bits = 1<<((year -1960)/10+2);14 double i=1;15 res =0;16 while(res<bits){17... 阅读全文
posted @ 2014-01-08 15:46 shaoshuai1990 阅读(226) 评论(0) 推荐(0) 编辑