Advertisement
erfanul007

UVa 583

Mar 13th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef unsigned long long int ull;
  5. typedef long long int ll;
  6. typedef vector<int> vi;
  7. typedef vector<ll> vll;
  8. typedef pair<int,int > pii;
  9. typedef vector< pii > vpii;
  10.  
  11. #define sc scanf
  12. #define pf printf
  13. #define sci(n) scanf("%d",&n)
  14. #define scl(n) scanf("%lld",&n)
  15. #define scf(n) scanf("%lf",&n)
  16. #define scs(s) scanf("%s",s)
  17. #define pfi(n) printf("%d",n)
  18. #define pfl(n) printf("%lld",n)
  19. #define pff(n) cout<<n
  20. #define line printf("\n")
  21. #define spc printf(" ")
  22. #define loop(i,x,y) for(int i=int(x); i<=int(y); i++)
  23. #define rloop(i,y,x) for(int i=int(y); i>=int(x); i--)
  24. #define cspf(i) printf("Case %d: ", i)
  25. #define pb push_back
  26. #define mp make_pair
  27. #define ff first
  28. #define ss second
  29. #define all(v) v.begin(),v.end()
  30. #define rall(v) v.rbegin(),v.rend()
  31. #define read() freopen("input.txt", "r", stdin)
  32. #define write() freopen("output.txt", "w", stdout)
  33. /// Constants
  34. #define eps 1e-9
  35. #define inf (1e9)+9
  36. #define PI acos(-1.0) // 3.1415926535897932
  37. #define MAX 1000009
  38.  
  39.  
  40. int main()
  41. {
  42. ll n;
  43. while(cin>>n && n){
  44. cout<<n<<" = ";
  45. vll div;
  46. if(n<0){
  47. cout<<"-1 x ";
  48. }
  49. ll x=abs(n);
  50. for(ll i=2;i*i<=abs(n);i++){
  51. if(x%i==0){
  52. div.pb(i);
  53. x/=i;
  54. i--;
  55. }
  56. }
  57. if(x!=1){
  58. div.pb(x);
  59. }
  60. for(int i=0;i<div.size();i++){
  61. if(i){
  62. pf(" x ");
  63. }
  64. cout<<div[i];
  65. }
  66. line;
  67. }
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement