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