結果
問題 | No.2326 Factorial to the Power of Factorial to the... |
ユーザー |
![]() |
提出日時 | 2023-05-28 13:50:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 665 bytes |
コンパイル時間 | 3,674 ms |
コンパイル使用メモリ | 228,088 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 22:02:14 |
合計ジャッジ時間 | 4,598 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include <stdio.h> #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; using mint = modint1000000007; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int main(){ long long n; cin>>n; long long p; cin>>p; mint ans = 0; { long long t = n; while(t!=0){ ans += t/p; t /= p; } } long long pp = 1000000006; long long cur = 1; rep(i,n){ cur *= i+1; cur %= pp+1; } long long cc = 1; rep(i,n){ cur = pow_mod(cur,i+1,pp+1); } cc = cur; // cout<<ans.val()<<','<<cc<<','<<cur<<endl; ans *= cc; cout<<ans.val()<<endl; return 0; }