結果

問題 No.2816 At Most Two Moves
ユーザー 沙耶花
提出日時 2024-07-19 22:16:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 799 bytes
コンパイル時間 4,138 ms
コンパイル使用メモリ 252,292 KB
最終ジャッジ日時 2025-02-23 16:39:29
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001

long long c(long long n,long long r){
	if(n<r)return 0;
	if(n==r)return 1;
	if(r==1)return n;
	return c(n-1,r-1)+c(n-1,r);
}

int main(){
	
	
	int _t;
	cin>>_t;
	rep(_,_t){
		long long n;
		cin>>n;
		if(n==1)cout<<1<<endl;
		else if(n==2)cout<<3<<endl;
		else{
			long long E = n;
			E *= n-1;
			E /= 2;
			mint ans = 1;
			ans *= mint(3).pow(n-2);
			ans /= mint(2).pow(n-2);
			ans /= mint(2).pow(n-1);
			ans *= mint(2).pow(E);
			ans *= n-1;
			mint t = mint(2).pow(E);
			t *= n;
			t -= ans;
			cout<<t.val()<<endl;
			
		}
	}
	
	return 0;
}
0