poj 3100 (zoj 2818)||ZOJ 2829 ||ZOJ 1938 (poj 2249)

2014-11-24 08:46:10 · 作者: · 浏览: 0

水题三题:

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
  
   
#include
   
     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
  
   
const int MAXN=300000;
int a[MAXN],len=1;
int main()
{
	for(int i=3;i
    
    


3.ZOJ 1938 Binomial Showdown (poj 2249)

http://poj.org/problem id=2249

http://acm.zju.edu.cn/onlinejudge/showProblem.do problemId=938

#include
     
      
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;
}