标签:can using printf lan algorithm mat string long 代码
http://172.20.6.3/Problem_Show.asp?id=1379
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<cmath> 6 using namespace std; 7 const int maxn=50100; 8 long long a,b1,b2,tot,tot1; 9 long long q[maxn]={}; 10 long long su[maxn]={}; 11 long long dfs(long long x,long long i){ 12 i+=1;long long y; 13 for(;;i++){ 14 y=q[i]; 15 if(x%y==0){ 16 long long ans=1,k=1; 17 while(x%y==0){ 18 x/=y,k*=y,ans+=k; 19 } 20 if(x==1)return ans; 21 return ans*dfs(x,i); 22 } 23 } 24 } 25 bool doit(long long x){ 26 if(a==1&&x==1)return 1; 27 tot1=0;long long ma=(long long)sqrt(double(x)); 28 for(int i=1;i<=ma;i++){ 29 if(x%i==0){ 30 q[++tot1]=i;q[++tot1]=x/i; 31 } 32 }sort(q+1,q+tot1+1); 33 if(dfs(x,1)==a)return 1; 34 return 0; 35 } 36 int main(){ 37 while(~scanf("%I64d%I64d%I64d",&a,&b1,&b2)){ 38 if(a==0&&b1==0&&b2==0){break;} 39 long long w=a*b2; 40 if(w%b1==0){ 41 if(doit(w/b1))printf("%d %I64d\n",1,w/b1); 42 else printf("%d\n",0); 43 } 44 else printf("%d\n",0); 45 } 46 return 0; 47 }
标签:can using printf lan algorithm mat string long 代码
原文地址:http://www.cnblogs.com/137shoebills/p/7787013.html