Submission #1260701

#TimeUsernameProblemLanguageResultExecution timeMemory
1260701wedonttalkanymoreUzastopni (COCI17_uzastopni)C++20
80 / 80
1 ms328 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define int long long
#define pii pair<ll, ll>
#define fi first
#define se second

const ll N = 2e5 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 16;

int n;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    if (fopen(".inp", "r")) {
        freopen(".inp", "r", stdin);
        freopen(".out", "w", stdout);
    }
    cin >> n;
    int t = 2 * n;
    for (int j = 2; j * j <= t; j++) {
        if (t % j == 0) {
            int val1 = j;
            int val2 = t / j;
            val1--;
            if (!val1) continue;
            // cout << val1 << ' ' << val2 << ' ';
            int L = (val2 - val1) / 2;
            int R = (val1 + val2) / 2;
            if ((R + L) * (R - L + 1) / 2 != n) continue;
            // if (((R * (R + 1)) / 2) - ((L * (L - 1)) / 2) == n) continue; 
            cout << L << ' ' << R << '\n';
        }
    }
    return 0;
}

Compilation message (stderr)

uzastopni.cpp: In function 'int main()':
uzastopni.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen(".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
uzastopni.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen(".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...