摘要: Problem AChess QueenInput:Standard InputOutput:Standard OutputYou probably know how the game of chess is played and how chess queen operates. Two chess queens are in attacking position when they are on same row, column or diagonal of a chess board. Suppose two such chess queens (one black and the ot 阅读全文
posted @ 2014-02-23 16:04 悠悠我心。 阅读(268) 评论(0) 推荐(0) 编辑
摘要: Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem.The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese. Due to the lack of predators, the geese population was out of control. The people of Loowater mostly kept clear 阅读全文
posted @ 2014-02-23 08:43 悠悠我心。 阅读(232) 评论(0) 推荐(0) 编辑
摘要: A. NineteenAlice likes word "nineteen" very much. She has a stringsand wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.For example, if she has string "xiineteenppnnnewtnee", she can get string "xnineteen 阅读全文
posted @ 2014-02-18 23:37 悠悠我心。 阅读(365) 评论(0) 推荐(0) 编辑
摘要: zxp学长告诉我两种计算pi值得办法,第一种是pi/4=1-1/3+1/5-1/7……(课本上的传统方法)第二种方法是这种方法的证明(以上由zxp学长找的资料给我的……)用C++写出这两种方法求解pi的过程,然后比较这两种方法收敛的速度 1 #include 2 #include 3 #include 4 using namespace std; 5 int main(){ 6 double pi1=0; 7 double pi2; 8 for(double i=0;i<1500000;i++){//the method in text book should use ... 阅读全文
posted @ 2014-02-17 21:42 悠悠我心。 阅读(4695) 评论(1) 推荐(0) 编辑
摘要: Manao is designing the genetic code for a new type of algae to efficiently produce fuel. Specifically, Manao is focusing on a stretch of DNA that encodes one protein. The stretch of DNA is represented by a string containing only the characters 'A', 'T', 'G' and 'C'.Ma 阅读全文
posted @ 2014-02-17 20:26 悠悠我心。 阅读(253) 评论(0) 推荐(0) 编辑
摘要: B.WordFoldingYouwillreceive5pointsforsolvingthisproblem.Manaohasinventedanewoperationonstringsthatiscalledfolding.Eachfoldhappensbetweenapairofconsecutivelettersandplacesthesecondpartofthestringabovefirstpart,runningintheoppositedirectionandalignedtothepositionofthefold.Usingthisoperation,Manaoconve 阅读全文
posted @ 2014-02-17 12:51 悠悠我心。 阅读(318) 评论(0) 推荐(0) 编辑
摘要: 390 A. Inna and Alarm Clockhttp://codeforces.com/contest/390/problem/A水题一枚,两个set就可完成 1 #include 2 #include 3 #include 4 using namespace std; 5 6 sets1,s2; 7 8 int main() 9 {10 int n,a,b;11 while(cin>>n)12 {13 s1.clear();14 s2.clear();15 while(n--)16 {17 ... 阅读全文
posted @ 2014-02-16 09:34 悠悠我心。 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 题意:n种硬币围城一个圈,每人可取一个或连续两个,取出后就留下空格,取走最后一个硬币的人赢。分析:1、n==1||n==2 明显先手赢2、n==3 明显 后手赢3、 n>=4 若n为偶数则无论先手取一个或者是两个 后手肯定会在相对的位置取相同的数目 所以先手必败 若n位奇数 若先手取一个则后手可在相对的位置取两个使其变成偶数 若先手去两个同理所以 先手必败 阅读全文
posted @ 2014-02-14 23:20 悠悠我心。 阅读(305) 评论(0) 推荐(0) 编辑
摘要: 一、动态规划:如果一句话总结的的话,我觉得dp是这样的:动态规划是用空间换时间的一种方法的抽象,其关键是发现子问题和记录其结果,然后利用这些结果减轻运算量。二、01背包思路:主要的有两点:1 f[i][v]=max{f[i-1][v],f[i-1][v-c[i]]+w[i]}2三、代码:以HDU2602为例1 二维递推版 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int maxn=1005; 7 8 int dp[maxn][maxn]; 9 10 int va[maxn],vo[maxn];11 1.. 阅读全文
posted @ 2014-02-05 18:27 悠悠我心。 阅读(722) 评论(0) 推荐(0) 编辑
摘要: 这个题做过一遍了:那个貌似比这个还难点,stl库函数就可以实现:#include#include///next_permutationµÄÐèÒª#includeusingnamespacestd;intmain(){intn,t,i,j,k,a[10001];cin>>t;while(t--){cin>>n;for(i=0;i>a[i];}next_permutation(a,a+n);for(i=0;i<n;i++){printf(i==0?"%d":"%d&quo 阅读全文
posted @ 2014-01-24 22:42 悠悠我心。 阅读(116) 评论(0) 推荐(0) 编辑