結果

問題 No.375 立方体のN等分 (1)
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2016-06-04 23:08:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,057 bytes
コンパイル時間 2,075 ms
コンパイル使用メモリ 177,788 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 01:02:48
合計ジャッジ時間 2,936 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 3 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 WA -
testcase_26 AC 4 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 4 ms
5,376 KB
testcase_29 AC 6 ms
5,376 KB
testcase_30 AC 5 ms
5,376 KB
testcase_31 AC 4 ms
5,376 KB
testcase_32 AC 6 ms
5,376 KB
testcase_33 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;

map<ll, int> enumdiv(ll n) {
	map<ll, int> V;
	if (n == 1) V[1] = 1;
	else {
		for (ll i = 2; i*i <= n; i++) while (n%i == 0) V[i]++, n /= i;
		if (n>1) V[n]++;
	}
	return V;
}

ll N;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	while (cin >> N)
	{
		auto ps = enumdiv(N);
		vector<ll> primes;
		for (auto p : ps) rep(i, 0, p.second) primes.push_back(p.first);

		if (primes.size() == 1)
		{
			cout << (N - 1) << " " << (N - 1) << endl;
			continue;
		}

		if (primes.size() == 2)
		{
			cout << (primes[0] + primes[1] - 2) << " " << (N - 1) << endl;
			continue;
		}

		if (primes.size() == 3)
		{
			cout << (primes[0] + primes[1] + primes[2] - 3) << " " << (N - 1) << endl;
			continue;
		}

		rep(i, 0, primes.size() - 3)
		{
			sort(primes.begin() + i, primes.end());
			primes[i + 1] *= primes[i];
		}

		ll ans = 0;
		rep(i, primes.size() - 3, primes.size()) ans += primes[i] - 1;
		cout << ans << " " << (N - 1) << endl;
	}
}
0