Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- void tinh(ll n, ll i){
- ll l, r;
- if (i%2 == 1){
- l = n/i - 1; r = l + 2;
- if ((l+r)*(i/2) + (l+r)/2 == n)
- cout << l - (i/2) + 1 << ' ' << r + (i/2) - 1 << '\n';
- }
- else{
- l = n/i; r = l + 1;
- if ((l+r)*(i/2) == n)
- cout << l - (i/2) + 1 << ' ' << r + (i/2) - 1 << '\n';
- }
- }
- int main() {
- freopen("INVEST.inp", "r", stdin);
- freopen("INVEST.out", "w", stdout);
- ios_base::sync_with_stdio(false);
- cin.tie(0); cout.tie(0);
- ll n; cin >> n;
- for(ll i = 2; i*(i-1)/2 <= n; ++i)
- tinh(n, i);
- return 0;
- }
- /*
- 20
- 2+3+4+5+6
- giua * (slpt/2) + giua
- */
Advertisement
Add Comment
Please, Sign In to add comment