結果
| 問題 |
No.2318 Phys Bone Maker
|
| コンテスト | |
| ユーザー |
planes
|
| 提出日時 | 2023-05-26 22:24:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,443 bytes |
| コンパイル時間 | 1,840 ms |
| コンパイル使用メモリ | 182,840 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-25 08:10:28 |
| 合計ジャッジ時間 | 11,981 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
ll INF=2e18;
const ll mod=998244353;
vector<ll> yaku,nso;
ll N;
map<ll,ll> S;
long long GCD(long long a, long long b) {
if (b == 0) return a;
else return GCD(b, a % b);
}
ll solve(ll k) {
if(k==N) return 1;
if(S.count(k)) return S[k];
ll ans=0;
for(ll i=0;i<yaku.size();i++) {
if(yaku[i]%k==0&&yaku[i]>k) {
ll d=yaku[i]/GCD(yaku[i],k);
ll s=1;
for(auto x:nso) {
if(k%x==0&&d%x!=0) {
ll t=k;
ll count=1;
while(t%x==0) {
t/=x;
count++;
}
s*=count;
s%=mod;
}
}
ans+=s*solve(yaku[i])%mod;
ans%=mod;
}
}
S[k]=ans;
return ans;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin>>N;
yaku=vector<ll> (0);
for(ll i=1;i<=sqrt(N);i++) {
if(N%i==0) {
ll a=N/i;
if(i!=a) {
yaku.push_back(a);
yaku.push_back(i);
}
else yaku.push_back(i);
}
}
sort(all(yaku));
ll ma=1000000+100;
vector<bool> note(ma,false);
vector<ll> so(0);
for(ll i=2;i<ma;i++) {
if(note[i]) continue;
so.push_back(i);
for(ll j=1;j*i<ma;j++) note[j*i]=true;
}
nso=vector<ll> (0);
for(auto x:so) {
if(N%x==0) nso.push_back(x);
}
ll ans=solve(1);
if(ans<0) ans+=mod;
cout<<ans<<endl;
}
planes