Advertisement
Saleh127

Spoj FACT0

Jul 6th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9. ll a,c,d,e,f,i,j,k,l;
  10. while(cin>>a && a)
  11. {
  12. if(a%2==0)
  13. {
  14. c=0;
  15. while(a%2==0)
  16. {
  17. c++;
  18. a/=2;
  19. }
  20. cout<<2<<"^"<<c<<" ";
  21. }
  22. for(i=3;i*i<=a;i+=2)
  23. {
  24. if(a%i==0)
  25. {
  26. c=0;
  27. while(a%i==0)
  28. {
  29. c++;
  30. a/=i;
  31. }
  32. cout<<i<<"^"<<c<<" ";
  33. }
  34. }
  35. if(a>1) cout<<a<<"^1";
  36. cout<<endl;
  37. }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement