結果

問題 No.944 煎っぞ!
ユーザー CELICACELICA
提出日時 2020-09-30 19:54:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 3,000 ms
コード長 929 bytes
コンパイル時間 1,565 ms
コンパイル使用メモリ 170,400 KB
実行使用メモリ 8,212 KB
最終ジャッジ日時 2023-09-20 13:13:37
合計ジャッジ時間 5,183 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
8,084 KB
testcase_01 AC 34 ms
8,052 KB
testcase_02 AC 34 ms
8,012 KB
testcase_03 AC 34 ms
8,076 KB
testcase_04 AC 34 ms
8,040 KB
testcase_05 AC 35 ms
8,104 KB
testcase_06 AC 35 ms
8,044 KB
testcase_07 AC 34 ms
7,920 KB
testcase_08 AC 34 ms
8,212 KB
testcase_09 AC 34 ms
8,212 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 7 ms
4,380 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 7 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 AC 7 ms
4,380 KB
testcase_20 AC 36 ms
8,032 KB
testcase_21 AC 34 ms
8,052 KB
testcase_22 AC 34 ms
8,148 KB
testcase_23 AC 34 ms
7,996 KB
testcase_24 AC 34 ms
7,972 KB
testcase_25 AC 34 ms
8,100 KB
testcase_26 AC 35 ms
8,136 KB
testcase_27 AC 33 ms
7,620 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 36 ms
7,940 KB
testcase_31 AC 45 ms
8,212 KB
testcase_32 AC 40 ms
8,056 KB
testcase_33 AC 37 ms
8,032 KB
testcase_34 AC 37 ms
8,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0