結果
| 問題 |
No.2798 Multiple Chain
|
| コンテスト | |
| ユーザー |
mogura
|
| 提出日時 | 2024-07-09 23:21:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,902 bytes |
| コンパイル時間 | 4,179 ms |
| コンパイル使用メモリ | 233,960 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-09 23:21:45 |
| 合計ジャッジ時間 | 6,304 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 46 WA * 5 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a));
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a),0LL)
using ll=long long;
using ld=long double;
using ull=unsigned long;
ll MOD=998244353;
using mint = static_modint<998244353>;
const int dx[]={0,1,0,-1,1,-1,1,-1};const int dy[]={1,0,-1,0,1,1,-1,-1};
const string ALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZ";const string alpha="abcdefghijklmnopqrstuvwxyz";
long long partition(int n) {
vector<long long> p(n + 1, 0);
p[0] = 1LL; // 空の和の方法が1つ(何も選ばない)
for (int k = 1; k <= n; ++k) {
for (int i = k; i <= n; ++i) {
p[i] += p[i - k];
}
}
return p[n];
}
vector<pair<long long, int>> prime_factors(long long n) {
vector<pair<long long, int>> factors;
// 2で割れるだけ割る
while (n % 2 == 0) {
if (factors.empty() || factors.back().first != 2) {
factors.push_back({2, 0});
}
factors.back().second++;
n /= 2;
}
// 3以上の奇数で割り続ける
for (long long i = 3; i * i * i-1 <= n; i += 2) {
while (n % i == 0) {
if (factors.empty() || factors.back().first != i) {
factors.push_back({i, 0});
}
factors.back().second++;
n /= i;
}
}
// nが素数の場合
if (n > 1) {
factors.push_back({n, 1});
}
return factors;
}
int main(){
cin.tie(nullptr);
cout.tie(nullptr);
ios::sync_with_stdio(false);
ll n;cin>>n;
int ans=1;
vector<pair<long long, int>> factors = prime_factors(n);
for(ll i=0;i<factors.size();i++){
ans*=partition(factors[i].second);
}
cout<<ans<<endl;
}
mogura