結果

問題 No.2318 Phys Bone Maker
ユーザー planesplanes
提出日時 2023-05-26 22:24:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,443 bytes
コンパイル時間 1,784 ms
コンパイル使用メモリ 181,084 KB
実行使用メモリ 4,556 KB
最終ジャッジ日時 2023-08-26 12:24:44
合計ジャッジ時間 12,785 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,376 KB
testcase_01 AC 10 ms
4,380 KB
testcase_02 AC 1,145 ms
4,456 KB
testcase_03 AC 16 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 16 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 12 ms
4,380 KB
testcase_08 AC 17 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 19 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 21 ms
4,440 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 16 ms
4,380 KB
testcase_23 AC 17 ms
4,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 18 ms
4,380 KB
testcase_27 AC 20 ms
4,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 11 ms
4,376 KB
testcase_34 AC 19 ms
4,376 KB
testcase_35 AC 117 ms
4,376 KB
testcase_36 AC 527 ms
4,380 KB
testcase_37 AC 560 ms
4,376 KB
testcase_38 AC 581 ms
4,380 KB
testcase_39 AC 790 ms
4,380 KB
testcase_40 AC 868 ms
4,380 KB
testcase_41 AC 931 ms
4,380 KB
testcase_42 AC 975 ms
4,380 KB
testcase_43 AC 23 ms
4,380 KB
testcase_44 AC 173 ms
4,380 KB
testcase_45 AC 164 ms
4,444 KB
testcase_46 AC 1,036 ms
4,556 KB
testcase_47 AC 21 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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



0