摘要: //蟠桃记//思路://天数 吃掉个数 剩余个数 吃掉与剩余的关系//0 0 F(0)//1 F(0)/2+1 F(1) = F(0)/2-1//2 F(1)/2+1 F(1) = F(1)/2-1//..............................................//n-2 F(n-3)/2+1 F(n-2) = F(n-3)/2-1//n-1 F(n-2)/2+1 ... 阅读全文
posted @ 2010-04-25 20:44 北海小龙 阅读(158) 评论(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) 编辑
摘要: n个平面最多分空间为几个部分的问题首先,可以通过直观想象1-3个平面最多分空间为几个部分。1个平面最多将空间分为2部分; 2个平面最多将空间分为4部分; 3个平面最多将空间分为8部分。若要第四个平面将空间分为最多部分,就要它与前三个平面都相交,且交线不重合。则第四个平面与前三个平面都相交,交线不重合,有三条交线,这三条交线都在第四个平面内,那么要想使这四个平面分空间为最多部分就要使这三条交线分一个... 阅读全文
posted @ 2010-04-25 20:43 北海小龙 阅读(269) 评论(0) 推荐(0) 编辑
摘要: //错排问题//思路:错排公式:d[n]= (n-1)*( d[n-1] + d[n-2])#include <iostream>#include <stdio.h>using namespace std;int main(){int n;while(cin>>n){//注意使用__int64,否则会溢出__int64 a=0,b=1;__int64 resul... 阅读全文
posted @ 2010-04-25 20:43 北海小龙 阅读(194) 评论(0) 推荐(0) 编辑
摘要: //求最小公倍数#include <iostream>#include <math.h>using namespace std;int big(int a,int b);int main(){int a,b;while(cin>>a>>b){int big_data = big(a,b);//两个数互素if(big_data == 1)cout<... 阅读全文
posted @ 2010-04-25 20:42 北海小龙 阅读(206) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <string>#include <iostream>using namespace std;int main(){int case_num;cin>>case_num;for(int i=0;i<case_num;i++){//注:不能使用char类型,否则会读取开头的空白符,使用stri... 阅读全文
posted @ 2010-04-25 20:42 北海小龙 阅读(233) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std;double return_result(double x1,double x2,double x3,double y1,double a);int main(){int case_num;double x1,y1;double x2,y2;double x3,y3;double a;double resul... 阅读全文
posted @ 2010-04-25 20:41 北海小龙 阅读(317) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std;int main(){int line;cin>>line;int i=0;//c++中动态数组的分配int *sum_p = new int[line];int p =line;for(;p>0;p--){int sum=0;int number;cin>>number;for... 阅读全文
posted @ 2010-04-25 20:41 北海小龙 阅读(264) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <stdio.h>#include <ctype.h>#include <string>//注意c++中string库和c中的string.h库不同using namespace std;int main(){ while(1){string str;getline(cin,str);if(st... 阅读全文
posted @ 2010-04-25 20:40 北海小龙 阅读(215) 评论(0) 推荐(0) 编辑
摘要: //求N^N的个位数//思路:只计算个位数的乘积,个位数最后形成一个循环#include <iostream>#include <string>#include <vector>using namespace std;int main(){int num;cin>>num;for(int i=0;i<num;i++){vector<int... 阅读全文
posted @ 2010-04-25 20:40 北海小龙 阅读(308) 评论(0) 推荐(0) 编辑