結果
| 問題 |
No.944 煎っぞ!
|
| コンテスト | |
| ユーザー |
CELICA
|
| 提出日時 | 2020-09-30 19:54:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 3,000 ms |
| コード長 | 929 bytes |
| コンパイル時間 | 1,653 ms |
| コンパイル使用メモリ | 173,888 KB |
| 実行使用メモリ | 8,192 KB |
| 最終ジャッジ日時 | 2024-07-06 08:30:52 |
| 合計ジャッジ時間 | 4,040 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;
int getFactors(const ll n, set<ll>& f)
{
int res{ 0 };
for (ll i = 1; i * i <= n; ++i)
{
if (n % i == 0)
{
f.insert(i);
++res;
auto p = f.insert(n / i);
if (p.second)
++res;
}
}
return res;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
cin >> n;
set<ll> sum;
ll t{ 0 };
ll a;
for (int i = 0; i < n; ++i)
{
cin >> a;
t += a;
sum.insert(t);
}
ll res{ 1 };
if (n > 1)
{
set<ll> s;
getFactors(t, s);
auto it = s.end();
s.erase(--it);
for (auto it = s.begin();
it != s.end();
++it)
{
bool f{ true };
for (int j = 1; j <= t / *it; ++j)
{
if (!sum.count(*it * j))
{
f = false;
break;
}
}
if (f)
{
res = t / *it;
break;
}
}
}
cout << res << "\n";
return 0;
}
CELICA