a53

cate3cifre

a53
Mar 14th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <fstream>
  2.  
  3. using namespace std;
  4. int C[4], B[4];
  5. int n, m, i, st, dr, mid, j, nr, baza, cifra, k, t;
  6.  
  7. ifstream fin ("cate3cifre.in");
  8. ofstream fout("cate3cifre.out");
  9.  
  10. int main () {
  11. fin>>t>>n;
  12.  
  13. for (i=n;i>=2;i--) {
  14. nr = 0;
  15. for (baza=2;1+baza+baza*baza<=i;baza++) {
  16. if (i%(1+baza+baza*baza) != 0)
  17. continue;
  18.  
  19. cifra = i/(1+baza+baza*baza);
  20. if (cifra < baza) {
  21. nr++;
  22. C[nr] = cifra;
  23. B[nr] = baza;
  24. if (nr == 3)
  25. break;
  26. }
  27. }
  28. if (nr == 2) {
  29. if (t == 1)
  30. fout<<i;
  31. else
  32. fout<<B[1]<<" "<<C[1]<<"\n"<<B[2]<<" "<<C[2]<<"\n";
  33. return 0;
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment