Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

粘贴个0MS的东东给大家交流交流

Posted by ybc_c at 2010-08-16 17:51:55 on Problem 3100
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
//#define LOCAL
int Mul(int a,int n){
	int s=1;
	int i;
	if(a==1) return 1;
	for(i=1;i<=n;i++)
		s*=a;
	return s;
}
int main()
{
#ifdef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int b,n;
	while(2){
		scanf("%d%d",&b,&n);
		if(!b && !n) break;
		int dis=0,a=1;
		int s,t;
		s=Mul(a,n);
		while(s<b){
			dis=b-s;
			t=a;
			a++;
			s=Mul(a,n);
		}
		if(s==b) printf("%d\n",a);
		else{
			int k;
			k=s-b;
			if(dis<k) printf("%d\n",t);
			else printf("%d\n",a);
		}
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator