摘要: 求在N中取M的个数,简单的组合数。#include"iostream" using namespace std; int main() { int n,k; while(cin>>n>>k,n!=0||k!=0) { if(n-k<k)//根据组合数的公式尽量约去大的部分 k=n-k; int count=k; __int64 ans=1; while(count--) { ans*=n--; while(ans%k==0&&k>1)//组合数结果一定是整数 { ans/=k; k--; } } printf(" 阅读全文
posted @ 2011-05-04 22:58 Ac_smile 阅读(278) 评论(0) 推荐(0) 编辑
摘要: Write a program to convert numbers in one base to numbers in a second base. There are 62 different digits: { 0-9,A-Z,a-z } HINT: If you make a sequence of base conversions using the output of one conversion as the input to the next, when you get back to the original base, you should get the original 阅读全文
posted @ 2011-05-04 15:31 Ac_smile 阅读(586) 评论(0) 推荐(1) 编辑
摘要: Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!高精度处理,用字符串来存储。#include"iostream"using namespace std;char ans[35661];//10000的时候是35660位数int main(){ int n; while(cin>>n) { int i,digit=1; ans[0]=1; for(i=2;i<=n;i++) { int j,k; for(j=k=0;j<digit;j++) { int temp=ans[j] 阅读全文
posted @ 2011-05-04 13:27 Ac_smile 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 2176在简单的NIM游戏上输出取法策略AC代码:#include"iostream" using namespace std; int main() { int m; while(cin>>m,m) { int ans=0,i,s[200001]; for(i=0;i<m;i++) { cin>>s[i]; ans^=s[i]; } if(ans==0) { cout<<"No"<<endl; continue; } cout<<"Yes"<<endl; 阅读全文
posted @ 2011-05-04 12:41 Ac_smile 阅读(176) 评论(0) 推荐(0) 编辑