code for fun

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

2014年3月1日

摘要: Problem DescriptionThe three hands of the clock are rotating every second and meeting each other many times everyday. Finally, they get bored of this and each of them would like to stay away from the other two. A hand is happy if it is at least D degrees from any of the rest. You are to calculate ho 阅读全文
posted @ 2014-03-01 18:22 xueda120 阅读(458) 评论(0) 推荐(0) 编辑

摘要: 关于ACM的输入输出(一)一般来说ACM的现场赛会规定输入输出或者是文件输入标准输出也可能是文件输入文件输出如果没有规定的话那么一般就是标准的输入输出了那说一下输入输出的重定向一般用下面两种方法c++常用:#include ifstream filein("data.in"); // 定义一个文件输入流ofstream fileout("data.out"); //cout fileout>都要改成filein>>, cout> str) { } getline读字符串时遇到换行符结束,用于读一整行 char str[BUFFER 阅读全文
posted @ 2014-03-01 14:37 xueda120 阅读(2872) 评论(0) 推荐(1) 编辑

摘要: 所谓的快速幂,实际上是快速幂取模的缩写,简单的说,就是快速的求一个幂式的模(余)。在程序设计过程中,经常要去求一些大数对于某个数的余数,为了得到更快、计算范围更大的算法,产生了快速幂取模算法。我们先从简单的例子入手:求abmodc算法1.直接设计这个算法:int ans = 1;for(int i = 1;i0) { if(b % 2 = = 1) ans = (ans * a) % c; b = b/2; a = (a * a) % c; } return ans;}本算法的时间复杂度为O(logb),能在几乎所有的程序设计... 阅读全文
posted @ 2014-03-01 01:45 xueda120 阅读(427) 评论(0) 推荐(0) 编辑

摘要: Problem DescriptionA number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.Given A, B, and n, you are to calculate the value of f(n).InputThe input consists of multiple test cases. Each test case contains 3 integers A, B and n on a single line (1 using 阅读全文
posted @ 2014-03-01 01:20 xueda120 阅读(172) 评论(0) 推荐(0) 编辑