摘要:
//全部用long #include<stdio.h>long fun(int n,int m){ long long int a,b,ans=1; a=n-m+1; b=1; while(a<=n&&b<=m) { ans=ans*a/b; a++; b++; } return ans;}int main(){ long long int m,n,ans; while(scanf("%lld%lld",&n,&m),m||n) { ans=fun(n+m-1,m); printf("%lld\n" 阅读全文
摘要:
#include<stdio.h>int main(){ int m,n,a,b;int ans=1; scanf("%d%d",&n,&m); a=n-m+1; b=1; while(a<=n&&b<=m) { ans=ans*a/b; // printf("%d %d %d\n",a,b,ans);//调试 a++; b++; } printf("%d\n",ans); return 0;}//c(8,3)=6*7*8/(1*2*3)第二种方法c(n,m)=n!/(m!*(n 阅读全文
摘要:
#include<stdio.h>#include<string.h>#define N 10003int main(){ int i,T;int ans,len; scanf("%d",&T); while(T--) { //getchar();不可加 int ans=0; char num[1000000]; scanf("%s",num); getchar(); len=strlen(num); // for(i=0;i<len;i++) //printf("%d ",num[i]);//知 阅读全文