Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n,a,b,x,y;
  8. cin>>n;
  9. for (int i=1;i<=n;i++)
  10. {
  11. cin>>x>>y;
  12. a=x;
  13. b=y;
  14. while (b!=0)
  15. {
  16. int r=a%b;
  17. a=b;
  18. b=r;
  19. }
  20. x=x/a;
  21. y=y/a;
  22. int c2=0,c5=0;
  23. while (y%2==0)
  24. {
  25. c2++;
  26. y=y/2;
  27. }
  28. while (y%5==0)
  29. {
  30. c5++;
  31. y=y/5;
  32. }
  33. if (y==1) cout<<"fractie finita\n";
  34. else
  35. if (c2==0 && c5==0)
  36. cout<<"fractie periodica simpla\n";
  37. else cout<<"fractie periodica mixta\n";
  38. }
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement