結果

問題 No.1754 T-block Tiling
ユーザー あべしあべし
提出日時 2021-11-20 13:51:46
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,756 bytes
コンパイル時間 7,910 ms
コンパイル使用メモリ 133,808 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-09-02 07:45:23
合計ジャッジ時間 8,725 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

#define int ll
#define rep(i, N) for(int i = 0; i < (int)N; ++i)
#define rep1(i, N) for(int i = 1; i <= (int)N; ++i)
#define per(i, N) for(int i = N-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define TakAo(ans) ans ? cout << "Takahashi\n" : cout << "Aoki\n"
#define YesNo(ans) ans ? cout << "Yes\n" : cout << "No\n"
#define yesno(ans) ans ? cout << "yes\n" : cout << "no\n"
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define mkpr make_pair
#define mktpl make_tuple

using namespace std;
using ll = int64_t;
using ld = long double;

const ld EPS = 1e-8;
const ll INF = 1e9+10;
const int MOD = 998244353;
//const int MOD = 1e9+7;
const int NIL = -1;

ll cel(ll a, ll b){ return (a + b - 1) / b; }
ll Gcd(ll a, ll b){ return b ? Gcd(b, a % b) : a; }
ll Lcm(ll a, ll b){ return a / Gcd(a, b) * b; }
ll sq(ll a){ return a * a; }
template<class T> bool chmin(T &a, T b){ if(a > b){ a = b; return 1;} return 0; }
template<class T> bool chmax(T &a, T b){ if(a <= b){ a = b; return 1;} return 0; }

using P = pair<int, int>;
using Tpl = tuple<int, int, int>;
using vvec= vector<vector<int>>;
using vvvec = vector<vector<vector<int>>>;

int N, m[110][2];

ll dp(int n, bool isfill){
	if(m[n][isfill]) return m[n][isfill];
	if(n == N) return 1;

	ll res;
	if(isfill){
		res = (2 * dp(n+1, 0)) % MOD;
	}
	else{
		res = dp(n, 1);
		res = (res + dp(n+1, 0)) % MOD;
	}

	return m[n][isfill] = res;
}

void Main(){
	int T; cin >> T;
	while(T--){
		cin >> N;
	    rep(i, N+1) m[i][0] = m[i][1] = 0;
		cout << dp(0, 1) << endl;
	}
}

signed main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}
0