結果

問題 No.1186 長方形の敷き詰め
ユーザー DaYuanChi
提出日時 2021-01-26 20:46:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 861 ms / 2,000 ms
コード長 479 bytes
コンパイル時間 1,620 ms
コンパイル使用メモリ 173,528 KB
実行使用メモリ 144,000 KB
最終ジャッジ日時 2024-06-23 19:10:08
合計ジャッジ時間 4,314 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ll a[1000005];
map<ll, int> memo;
ll const mod = 998244353;

int n, m;

ll f(int i){
  if(memo.find(i)!=memo.end()) return memo[i];
  if(i<=n-1) return memo[i] = 1;
  else return memo[i] = (f(i-1)+f(i-n))%mod;
}


int main(){
  cin >> n >> m;
  if(n > m){
    cout << 1 << endl;
    return 0;
  }
  if(n==1){
    cout << 1 << endl;
    return 0;
  }
  if(n <= m){
    cout << f(m) << endl;
    return 0;
  }
}
0