Submission #379080

# Submission time Handle Problem Language Result Execution time Memory
379080 2021-03-17T09:33:16 Z gustason Uzastopni (COCI17_uzastopni) C++14
64 / 80
1000 ms 364 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18 + 5;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    for(int i = 2; i*i <= 3 * n; i++) {
//        if (i % 2 == 0 && n % i != i/2) continue;
//        if (i % 2 && n % i != 0) continue;

        ll l = 1, r = n;
        while(l <= r) {
            ll mid = (l + r) / 2;
            ll a0 = mid, an = mid + i - 1;
            if (a0 + an > INF / i || (i * (a0 + an)) / 2 > n) {
                r = mid - 1;
            } else if ((i * (a0 + an)) / 2 == n) {
                cout << a0 << " " << an << "\n";
                break;
            } else {
                l = mid + 1;
            }
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Execution timed out 1086 ms 364 KB Time limit exceeded
10 Execution timed out 1087 ms 364 KB Time limit exceeded