fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. ll n,k,d[100],l,h, bd = 0,x,y,z,sum,kq;
  5.  
  6. string s;
  7. int main()
  8. {
  9. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  10. freopen("HINHVUONG.inp", "r", stdin);
  11. freopen("HINHVUONG.out", "w", stdout);
  12. cin >> n >> k;
  13. kq=k;
  14. for(int i=2;i<=n;++i)
  15. {
  16. sum=k;
  17. x=i*i*(i-1)*(n+1)/2;
  18. sum-=x;
  19. y=i*i;
  20. if(sum%y==0&&sum>0)
  21. {
  22. ll t = sum/y;
  23. ll tam = t/n;
  24. tam*=n;
  25. t -= tam;
  26. if(t + i - 1 <= n)
  27. kq=min(kq,sum/y);
  28. }
  29. }
  30. cout<<kq;
  31. }
  32.  
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty