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 |
pow很牛啊#include<iostream> #include<math.h> using namespace std; #define UI unsigned __int64 int main() { UI hei,num,k,M,N=1; while(scanf("%I64u%I64u",&hei,&num) && (hei+num)) { if(num==1) { k=0; while(hei!=1) { hei/=2; k++; } printf("%I64u %I64u\n",k,(UI)pow(2,(double)(k+1))-1); continue; } for(k=1;;k++) { M=pow(hei,1.0/k)+0.9999999; N=pow(num,1.0/k)+0.9999999; if(M==N+1 && hei==(UI)pow(M,(double)k) && num==(UI)pow(N,(double)k)) break; } printf("%I64u %I64u\n",(num-1)/(N-1),hei*(N+1)-num*N); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator