Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
粘贴个0MS的东东给大家交流交流#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator