結果

問題 No.2752 文字列の数え上げ mod 998244353
ユーザー anonymouslyanonymously
提出日時 2024-05-10 22:30:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 2,054 ms
コンパイル使用メモリ 201,276 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-10 22:30:14
合計ジャッジ時間 4,027 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 1 ms
6,944 KB
testcase_20 AC 139 ms
6,940 KB
testcase_21 AC 219 ms
6,940 KB
testcase_22 AC 242 ms
6,940 KB
testcase_23 AC 222 ms
6,940 KB
testcase_24 AC 218 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const long mod = 998244353L;

/* mod 998244353における25の逆数 */
const long inv25 = 319438193L;

/* 26^L mod 998244353を求める */
long modpow(long L){
	long a=26L;
	long res=1L;
	long e=L;
	while(e){
		if(e&1){
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		e>>=1;
	}
	return res;
}

/*
 * 解:26*(26^L-1)/25
 */
int main(void){
	int T;
	cin >> T;
	for(int t=0;t<T;t++){
		long L;
		cin >> L;
		long res=(modpow(L)+mod-1)%mod;
		res=(res*26)%mod;
		res=(res*inv25)%mod;
		cout << res << endl;
	}
	return 0;
}
0