4939 Euro-Pull function
time limit: 1 sspace limit: KBtitle level: Diamonds Diamond SolvingTitle Description
Description
Enter a number n, output the number of integers less than n and N-intertextuality
Enter a description
Input Description
Contains multiple sets of data, ending at n=0
The number of test data groups is not much, do not have to hit the table after output
Output description
Output Description
A set of data rows
Sample input
Sample Input
364684
346
5432
11
24
0
2333333
233333333
0
233333333333333
2333333333333333333333333333333333333333333333333
Sample output
Sample Output
165120
172
2304
10
8
Data range and Tips
Data Size & Hint
1<n<9223372036854775807
Attention to detail optimization, otherwise the nineth set of data may time out
Category labels
Tags Click here to expandNo label
Step by step according to the teacher, converted into code, the results of data card memory.
40-Point Code (MLE)
#include <cstdio>#include<iostream>using namespacestd;#defineN 100001intn,a[n]={0};intMain () { while(SCANF ("%d", &n) = =1){ if(!n) Break; Doubles=N; inti,j; for(i=2;; i++){ if(n==1) Break; for(j=0;; J + +){ if(n%i) Break; N/=i; } A[i]=J; } intE=i; for(i=2; i<=e;i++){ if(!a[i])Continue; Doublet=i; S*=(1.0-1.0/t); } printf ("%d\n",(int) s); for(intI=1; i<=e;i++) a[i]=0; } return 0;}
Read the puzzle, optimize the code
AC Code:
#include <cstdio>#include<iostream>using namespacestd;intMain () {Long LongN,ans; while(cin>>N) { if(!n) Break; Ans=N; if(n%2==0){ while(n%2==0) n/=2; Ans/=2; } for(Long LongI=3; i*i<=n;i+=2){ if(n%i==0){ while(n%i==0) n/=i; Ans=ans/i* (I-1); } } if(n>1) ans=ans/n* (n1); cout<<ans<<Endl; } return 0;}
4939 Euler function [one in number theory with practice]