結果
| 問題 | No.3584 Camouflage Mole |
| コンテスト | |
| ユーザー |
ZeriToki
|
| 提出日時 | 2026-07-10 21:33:15 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 3,095 bytes |
| 記録 | |
| コンパイル時間 | 2,023 ms |
| コンパイル使用メモリ | 335,608 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2026-07-10 21:33:26 |
| 合計ジャッジ時間 | 3,895 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
const long long mod=998244353;
const long long mod2=469762049;
const long long mod100=1000000007;
struct MATH{
vector<ll>factorial;//階乗データ
vector<ll>factorial_inv;
void factorial_init(ll N,ll m){//階乗を入れる
assert(N>=0);
factorial.assign(N+1,0);
factorial_inv.assign(N+1,0);
ll p=1;
factorial[0]=1;
for(int i=1;i<=N;i++){
p=(p*i)%m;
factorial[i]=p;
}
factorial_inv[N]=modinv(factorial[N],m);
for(int i=N-1;i>=0;i--){
factorial_inv[i]=(factorial_inv[i+1]*(i+1))%m;
}
return;
}
ll power(ll a,ll b,ll m){//a^b
assert(b>=0);
a%=m;
if(a<0) a+=m;
ll p=a,Answer=1;
for(ll i=0;i<60;i++){
ll wari=(1LL<<i);
if((b/wari)%2==1){
Answer=(Answer*p)%m;
}
p=(p*p)%m;
}
return Answer;
}
ll Division(ll a,ll b,ll m){//a/b
return (a*power(b,m-2,m))%m;
}
ll modinv(ll x,ll m){//逆元
return power(x,m-2,m);
}
ll comb(ll n,ll r,ll m){//nCrを求める(factorial必要)
if(n<0 || r<0 || n-r<0) return 0;
ll res=factorial[n];
res=(res*factorial_inv[r])%m;
res=(res*factorial_inv[n-r])%m;
return res;
}
ll GCD(ll A,ll B){//GCD(A,B)
while(A>=1 && B>=1){
if(A>=B) A=(A%B);
else B=(B%A);
}
if(A!=0) return A;
return B;
}
ll modlog(ll a,ll b,ll m){//a^x=b(mod m)を満たす最小のx(ないなら-1)
a%=m;b%=m;
ll lo=-1,hi=m;
while(hi-lo>1){
ll mid=(lo+hi)/2;
if(mid*mid>=m) hi=mid;
else lo=mid;
}
ll sqrtM=hi;
map<ll,ll>baby;
ll amari=a;
for(ll r=1;r<sqrtM;r++){
if(!baby.count(amari)) baby[amari]=r;
amari=(amari*a)%m;
}
ll A=power(modinv(a,m),sqrtM,m);
amari=b;
for(ll q=0;q<sqrtM;q++){
if(amari==1 && q>=1) return q*sqrtM;
else if(baby.count(amari)) return q*sqrtM+baby[amari];
amari=(amari*A)%m;
}
return -1;
}
};
MATH math;
int main(){
cout.tie()->sync_with_stdio(0);
cin.tie(0);
int N;cin>>N;
ll dp[N+1][5];
for(int i=0;i<=N;i++){
for(int j=0;j<5;j++){
dp[i][j]=0;
}
}
dp[0][0]=1;
for(int i=1;i<=N;i++){
for(int j=0;j<5;j++){
dp[i][j]=(dp[i][j]+dp[i-1][j]*26)%mod;
}
dp[i][1]=(dp[i][1]+dp[i-1][0])%mod;
dp[i][2]=(dp[i][2]+dp[i-1][1])%mod;
dp[i][3]=(dp[i][3]+dp[i-1][2])%mod;
dp[i][4]=(dp[i][4]+dp[i-1][3])%mod;
}
cout<<dp[N][4]<<endl;
}
ZeriToki