poj 3100 (zoj 2818)||ZOJ 2829 ||ZOJ 1938 (poj 2249)
水题三题:
1.给你B和N,求个整数A使得A^n最接近B
2. 输出第N个能被3或者5整除的数
3.给你整数n和k,让你求组合数c(n,k)
1.poj 3100 (zoj 2818) Root of the Problem:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2818
http://poj.org/problem?id=3100
#include<cstdio> #include<cmath> int main() { int b,n; while(~scanf("%d%d",&b,&n),b||n) { int a=pow(b,1.0/n); int ans=a; if(b-pow(ans,n) > pow(ans+1,n)-b) ans++; printf("%d\n",ans); } return 0; }
2.ZOJ 2829 Beautiful Number
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1829
#include<cstdio> const int MAXN=300000; int a[MAXN],len=1; int main() { for(int i=3;i<MAXN;i++) if(i % 3==0 || i %5==0) a[len++]=i; int n; while(~scanf("%d",&n)) { printf("%d\n",a[n]); } return 0; }
http://poj.org/problem?id=2249
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=938
#include<cstdio> typedef long long LL; LL ans,n,k; int main() { while(scanf("%lld%lld",&n,&k),n) { ans=1; if(k == 0) { printf("1\n"); continue; } if(k > n-k )k=n-k; for(int i=1;i<=k;i++) { ans=ans*(n-i+1)/i; } printf("%lld\n",ans); } return 0; }
新 blog : www.hrwhisper.me