Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- typedef long long ll;
- int main() {
- int n;
- cin >> n;
- ll max_razlozuvanja = 0, broj = 0;
- for(int i = 0; i < n; i++) {
- ll k;
- cin >> k;
- int cnt = 0;
- for(ll x = 1; x * (x + 1) < 2 * k; x++) {
- double a = ((double) k - x * (x + 1) / 2) / (x + 1);
- if(a - (ll) a == 0.0) {
- cnt++;
- }
- if(max_razlozuvanja < cnt) {
- max_razlozuvanja = cnt;
- broj = k;
- }
- else if(max_razlozuvanja == cnt) {
- broj = min(broj, k);
- }
- }
- }
- cout << broj << " " << max_razlozuvanja + 1 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement