結果

問題 No.3799 1 + 6 = 7 (Another version)
ユーザー 👑 potato167
提出日時 2026-11-08 16:21:39
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 615µs
コード長 332 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,275 ms
コンパイル使用メモリ 217,708 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-11-13 22:04:54
合計ジャッジ時間 3,445 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
using mint = atcoder::modint998244353;
int main(){
	long N, M;
	cin >> N >> M;
	if ((mint(M + 1)).val()){
		cout << (((mint(M)).pow(N) + (mint(-1)).pow(N) * M) / (M + 1)).val() << "\n";
	}
	else{
		cout << ((mint(N - 1)) * (N & 1 ? 1 : -1)).val() << "\n";
	}
}
0