Advertisement
a53

fractie6

a53
Dec 31st, 2019
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n;
  7. cin>>n;
  8. int a,b;
  9. while(n--)
  10. {
  11. cin>>a>>b;
  12. int ca=a,cb=b,rest;
  13. while(cb!=0)
  14. rest=ca%cb,ca=cb,cb=rest;
  15. a=a/ca;
  16. b=b/ca;
  17. int cnt2=0,cnt5=0;
  18. while(b%2==0)
  19. ++cnt2,b/=2;
  20. while(b%5==0)
  21. ++cnt5,b/=5;
  22. if(b==1)
  23. cout<<"fractie finita"<<'\n';
  24. else
  25. {
  26. if(cnt2+cnt5==0)
  27. cout<<"fractie periodica simpla"<<'\n';
  28. else
  29. cout<<"fractie periodica mixta"<<'\n';
  30. }
  31. }
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement