Guest User

Untitled

a guest
Jul 19th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int ar[100001]={0},i,j,n=1000001,t,tot[100001],k;
  5. for(int p=0;p<n;p++)
  6. tot[p]=p;
  7. for(i=2;i<n;i++)
  8. {
  9. if(!ar[i])
  10. {
  11. for(j=i;j<n;j+=i)
  12. {
  13. ar[j]=1;
  14. tot[j]*=i-1;
  15. tot[j]/=i;
  16. }
  17. }
  18.  
  19. }
  20.  
  21. scanf("%d",&t);
  22. while(t--)
  23. {
  24. scanf("%d",&k);
  25. printf("%d\n",tot[k]);
  26.  
  27. }
  28.  
  29.  
  30. }
Add Comment
Please, Sign In to add comment