結果
| 問題 |
No.2798 Multiple Chain
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-07 09:32:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 2,000 ms |
| コード長 | 858 bytes |
| コンパイル時間 | 1,890 ms |
| コンパイル使用メモリ | 196,424 KB |
| 最終ジャッジ日時 | 2025-02-22 02:28:24 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 51 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
ll n, ans = 1;
cin >> n;
constexpr int r = 1'000'000;
vector<ll> dp(60);
dp[0] = 1;
for(int i = 1; i < 60; i++){
for(int j = 0; j + i < 60; j++){
dp[j + i] += dp[j];
}
}
auto f = [&](int v){
n /= v;
int cnt = 1;
while(n % v == 0){
n /= v;
cnt++;
}
ans *= dp[cnt];
};
if(n % 2 == 0) f(2);
if(n % 3 == 0) f(3);
for(int i = 5; i <= r; i += 4){
if(n % i == 0) f(i);
i += 2;
if(n % i == 0) f(i);
}
if(n > 1){
ll sqv = sqrtl(n);
while(sqv * sqv <= n) sqv++;
sqv--;
if(sqv * sqv == n) ans *= dp[2];
}
cout << ans << '\n';
}