fork(1) download
  1. #include <bits/stdc++.h>
  2.  
  3. #define ll long long
  4. #define pb push_back
  5.  
  6. const ll maxn=3e5+100;
  7. const ll mod=1e9+7;
  8.  
  9. using namespace std;
  10.  
  11. bool isprime(ll z){
  12. for (ll i = 2; i*i <= z; i++){
  13. if (z%i == 0){
  14. return false;
  15. break;
  16. }
  17. }
  18. return true;
  19. }
  20.  
  21. int main(){
  22. ll x, count=0,catet;
  23. cin>>x;
  24. ll d[9594], j=1, dd[9594];
  25. //inisiasi dd
  26. for(ll i=1; i<=9593; i++){
  27. dd[i]=0;
  28. d[i]=0;
  29. }
  30. //tabel bil. prima sebanyak 9593
  31. for(ll i=2; i<=100003; i++){
  32. if (isprime(i)){
  33. d[j]=i;
  34. j++;
  35. }
  36. }
  37. for(ll k=1; ; k++){
  38. if(x%d[k]==0){
  39. dd[d[k]]++;
  40. x-=(x/d[k]);
  41. }
  42. if(x==0){
  43. catet=d[k];
  44. break;
  45. }
  46. }
  47. for(ll l=1; ; l++){
  48. if(d[l]==catet){
  49. if(dd[d[l]]==1)
  50. cout<<d[l]<<endl;
  51. break;
  52. }
  53. else{
  54. cout<<d[l]<<"^"<<dd[d[l]]<<endl;
  55. break;
  56. }
  57. else if(dd[d[l]]==1) cout<<d[l]<<" x";
  58. else cout<<d[l]<<"^"<<dd[d[l]];
  59. }
  60. cout<< d[1];
  61. return 0;
  62. }
  63.  
  64.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
693
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:57:3: error: ‘else’ without a previous ‘if’
   else if(dd[d[l]]==1) cout<<d[l]<<" x";
   ^~~~
stdout
Standard output is empty