fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes her
  6. /*
  7. int x,y,p=2;
  8. cin>>x>>y; // 100 - 2
  9. cout << x <<"/"<< y << "\t";
  10. while(p<=x){
  11. if(x%p==0 && y%p==0){
  12. x /= p; // 50
  13. y /= p; // 2
  14. p = 2; //2
  15. cout << x <<"/"<< y << "\t";
  16. }else if(x%p==3 && y%p==3){
  17. x /= p; // 50
  18. y /= p; // 2
  19. p = 3; //2
  20. cout << x <<"/"<< y << "\t";
  21. }else
  22. p++; // 3
  23. }
  24. double z = x/y;
  25. if(y==1){
  26. cout << x;
  27. }else{
  28. cout << "SSSSS "<< x/2.0;
  29. }
  30. */
  31. double x=1.2;
  32. int y=1,z=1;
  33. //cout << int(x*z) %y << "\n";
  34. int counter=0;
  35. while(1){
  36. counter=0;
  37. int f=z; // 1
  38. int c=1;
  39. while(counter<10){
  40. if(int(x*f)==y){
  41. cout << y << "/" << f;
  42. c=2;
  43. break;
  44. }else{
  45. f++; // 2
  46. counter++; // 2
  47. }
  48. }
  49. if(c!=1) break;
  50. if(int(x*z)==y){
  51. cout << y << "/" << z;
  52. c=2;
  53. break;
  54. }else{
  55. y++;
  56. }
  57.  
  58. }
  59.  
  60. return 0;
  61. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
1/1