Submission #42377

# Submission time Handle Problem Language Result Execution time Memory
42377 2018-02-26T15:12:03 Z wasyl Uzastopni (COCI17_uzastopni) C++11
80 / 80
3 ms 752 KB
#include <bits/stdc++.h>
#ifndef dbg
#define dbg(...)
#endif
#define all(x) begin(x), end(x)
#define rsz(...) resize(__VA_ARGS__)
#define psh(...) push_back(__VA_ARGS__)
#define emp(...) emplace_back(__VA_ARGS__)
#define prt(...) print(cout, __VA_ARGS__)
#define dmp(...) print(cerr, #__VA_ARGS__, '=', __VA_ARGS__)
#define dprt(...) dbg(print(cerr,__VA_ARGS__))
#define ddmp(...) dbg(dmp(__VA_ARGS__))
using namespace std;using ll=long long;
template<typename t>using V=vector<t>;
template<typename t>void print(ostream& os, const t& a){os<<a<<'\n';}
template<typename t, typename... A>void print
(ostream& os, const t& a, A&&... b){os<<a<<' ';print(os, b...);}

inline ll foo (ll v)
{
    return (v * (v + 1)) >> 1;
}

ll n;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (ll i = 2, tmp; (tmp = n - foo(i)) >= 0; ++i)
        if (tmp >= 0 and tmp % i == 0)
            prt(tmp / i + 1, tmp / i + i);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 580 KB Output is correct
6 Correct 2 ms 684 KB Output is correct
7 Correct 2 ms 704 KB Output is correct
8 Correct 2 ms 744 KB Output is correct
9 Correct 2 ms 748 KB Output is correct
10 Correct 3 ms 752 KB Output is correct