摘要: //水题:但有值得借鉴的地方#include <stdio.h>int fun(int n);int main(){double sum[10];sum[0]=1;printf("n e\n");printf("- -----------\n");printf("0 %d\n",1);for(int n=1;n<10;n++){sum[n]=sum[n-1]+1.0/fun(n)... 阅读全文
posted @ 2010-04-25 20:48 北海小龙 阅读(253) 评论(0) 推荐(0) 编辑
摘要: //阿牛的EOF牛肉串//思路:递推求解 p[i] = 2*(p[i-2]+p[i-2])#include <iostream>using namespace std;int main(){int n;while(cin>>n){if(n==1)cout<<3<<endl;else if(n==2)cout<<8<<endl;... 阅读全文
posted @ 2010-04-25 20:47 北海小龙 阅读(215) 评论(0) 推荐(0) 编辑
摘要: //思路:主要使用错排公式//d[1] = 0 d[2] = 1 d[n] = (n-1)*(d[n-1]+d[n-2]) #include <iostream>using namespace std;__int64 fun(int n);int main(){int case_num;cin>>case_num;for(int i=0;i<case_num;i++)... 阅读全文
posted @ 2010-04-25 20:47 北海小龙 阅读(135) 评论(0) 推荐(0) 编辑
摘要: //考新郎//思路:在错排公式的基础上加入排列组合的因素#include <iostream>using namespace std;__int64 fun(int n);int main(){int case_num;cin>>case_num;for(int i=0;i<case_num;i++){int n,m;while(cin>>n>>... 阅读全文
posted @ 2010-04-25 20:47 北海小龙 阅读(162) 评论(0) 推荐(0) 编辑
摘要: //LELE的RPG难题//思路:使用递推求解 p[i] = p[i-1] + 2*p[i-2]//其中p[i-1]表示i个中第i-1个格与第1个格的颜色不同,p[i-2]表示第i-1个格和//第1个格的颜色相同但是第i-2个格肯定与i-1个格颜色不同,种类数为p[i-2],又//因为第i-1个格和第1个格颜色相同时,第i个格可以有其余两种颜色,所以乘以2.//注:从第四个开始满足这种规律#inc... 阅读全文
posted @ 2010-04-25 20:46 北海小龙 阅读(412) 评论(0) 推荐(0) 编辑
摘要: //思路:f(n) = f(n-1)+f(n-2) 使用递推求解//从图中也可以观察出来,第N张牌的排列可以又N-1张牌的排列再在末尾加上一张竖的牌。这样依然合法。也可以在N-2张合法排列的牌后面加上两张横着放的牌(如果竖着放就和上面一种重复了)。#include <iostream>#include <stdio.h>using namespace std;int mai... 阅读全文
posted @ 2010-04-25 20:46 北海小龙 阅读(287) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std;int mul(int a,int b);int main(){int a,b;int result;while(cin>>a>>b){if(a==0 && b==0)return 0;cout<<mul(a%1000,b)<<endl;}ret... 阅读全文
posted @ 2010-04-25 20:45 北海小龙 阅读(330) 评论(0) 推荐(0) 编辑
摘要: //超级楼梯//思路:使用递推求解 p[n] = p[n-1] + p[n-2]#include <iostream>using namespace std;int main(){int case_number;cin>>case_number;for(int i=0;i<case_number;i++){int m;cin>>m;if(m==2)cout... 阅读全文
posted @ 2010-04-25 20:45 北海小龙 阅读(183) 评论(0) 推荐(0) 编辑
摘要: // 一只小蜜蜂//思路:递推求解 p[i] = p[i-1] + p[i-2]//详细解题报告见word文档#include <iostream>using namespace std;int main(){int case_num;cin>>case_num;for(int i=0;i<case_num;i++){int a,b;cin>>a>&... 阅读全文
posted @ 2010-04-25 20:45 北海小龙 阅读(240) 评论(0) 推荐(0) 编辑
摘要: //计算直线的交点数//m条直线的交点方案数//=(m-r)条平行线与r条直线交叉的交点数 + r条直线本身的交点方案//=(m-r)*r+r条之间本身的交点方案数(1<=r<=m)#include <iostream>#include <vector>using namespace std;int main(){//使用多维数组实现,用到vector<i... 阅读全文
posted @ 2010-04-25 20:44 北海小龙 阅读(338) 评论(0) 推荐(0) 编辑