赵乐ACM

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2012年4月5日

摘要: 1. 算法:从一个节点开始,假如是r,如果下一个是r或者w,继续,一直到下一个为b为止,然后从b开始看下一个,如果是b或者w,继续,如果是r停止,处理“环”的问题,用了求余,可以使结尾的下一个变成第一个,但是要注意,最后结果不能大于n。2. 这是O(n^2) 的复杂度吧。/* ID: dollarzhaole PROG: beads LANG: C++ */ #include #include #include using namespace std; int main() { ofstream fout ("beads.out"); ifstream fin (" 阅读全文
posted @ 2012-04-05 20:39 赵乐ACM 阅读(176) 评论(0) 推荐(0)

摘要: 1. 蔡勒公式:来自百度百科w:星期; w对7取模得:0-星期日,1-星期一,2-星期二,3-星期三,4-星期四,5-星期五,6-星期六 c:世纪(前两位数) y:年(后两位数) m:月(m大于等于3,小于等于14,即在蔡勒公式中,某年的1、2月要看作上一年的13、14月来计算,比如2003年1月1日要看作2002年的13月1日来计算) d:日 [ ]代表取整,即只要整数部分。 下面以中华人民共和国成立100周年纪念日那天(2049年10月1日)来计算是星期几,过程如下: w=y+[y/4]+[c/4]-2c+[26(m+1)/10]+d-1 =49+[49/4]+[20/4]... 阅读全文
posted @ 2012-04-05 17:14 赵乐ACM 阅读(137) 评论(0) 推荐(0)

摘要: 1. 文件输入输出好别扭;2. 第一次没注意到cas--之后for循环就没作用了,得不到结果。/* ID: dollarzhaole PROG: gift1 LANG: C++ */ #include #include #include using namespace std; struct Node { string name; int sendp;//送给几个人 int getm;//收到的钱 int sendm;//送出去的钱 int inim;//刚开始的钱 } node[11]; int cas; int getname(string s... 阅读全文
posted @ 2012-04-05 15:31 赵乐ACM 阅读(192) 评论(0) 推荐(0)

摘要: 1. 从今天开始做USACO了,系统的学习下;2. 有详细的解题报告,可以看人家的代码,使自己的代码更简洁,更规范。/* ID: dollar4 PROG: ride LANG: C++ */ #include #include #include using namespace std; long getnum(string str) { long num = 1; for (unsigned int i = 0; i > str1 >> str2; num1 = getnum(str1); num2 = getnum(str2); if (n... 阅读全文
posted @ 2012-04-05 13:18 赵乐ACM 阅读(157) 评论(0) 推荐(0)