#12507: 逾時


0822_137934 (14306)

School : 臺北市私立延平高級中學
ID : 60259
IP address : [119.14.210.98]
Last Login :
2022-12-27 23:22:35
d440. 10299 - Relatives -- UVa10299 | From: [122.147.19.162] | Post Date : 2017-08-03 19:30

#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
long long int a;
while(cin>>a,a)
{long long int b=a;
for(int i=2;i<=a;i+=(i==2?1:2))
{if(a%i) continue;
b*=(1-1.0/i);
while(a%i==0) {a/=i;}
}
if(b==a){b--;}
cout<<b<<endl;
}
return 0;
}

請問如何改進?

 

 
#12508: Re:逾時


icube (!@#$%^&*()_+)

School : 國立臺灣師範大學附屬高級中學
ID : 61090
IP address : [220.135.116.184]
Last Login :
2024-04-01 14:01:32
d440. 10299 - Relatives -- UVa10299 | From: [220.135.116.184] | Post Date : 2017-08-03 20:06


http://acm.nudt.edu.cn/~twcourse/Euler'sPhiFunction.html

 
ZeroJudge Forum