Saleh127

UVA 12090/live 2195

Dec 18th, 2020 (edited)
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5.  
  6. ll fzero(ll n,ll b)
  7. {
  8. ll c=0;
  9. while(n%b==0)
  10. {
  11. n/=b;
  12. c++;
  13. }
  14. return c;
  15. }
  16.  
  17. int main()
  18. {
  19. ios_base::sync_with_stdio(0);
  20. cin.tie(0);cout.tie(0);
  21.  
  22. ll a,b,c,d,i;
  23. while(cin>>a && a)
  24. {
  25. if(a==1)
  26. {
  27. cout<<1<<" "<<0<<endl;
  28. continue;
  29. }
  30.  
  31. c=fzero(a,a);
  32.  
  33. for(i=2;i*i<a;i++)
  34. {
  35. if(a%i==0)
  36. {
  37. c+=fzero(a,i);
  38. c+=fzero(a,a/i);
  39. }
  40. }
  41. if(i*i==a)
  42. {
  43. c+=fzero(a,i);
  44. }
  45.  
  46. cout<<a<<" "<<c<<endl;
  47. }
  48.  
  49.  
  50. return 0;
  51. }
  52.  
Add Comment
Please, Sign In to add comment