結果
問題 |
No.1186 長方形の敷き詰め
|
ユーザー |
![]() |
提出日時 | 2020-08-22 18:00:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 2,067 bytes |
コンパイル時間 | 1,433 ms |
コンパイル使用メモリ | 167,832 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-10-15 11:54:24 |
合計ジャッジ時間 | 2,462 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
/** * @FileName a.cpp * @Author kanpurin * @Created 2020.08.22 17:55:02 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; constexpr int MOD = 998244353; struct mint { private: long long x; public: mint(long long x = 0) :x((MOD+x)%MOD) {} mint(std::string &s) { long long z = 0; for (int i = 0; i < s.size(); i++) { z *= 10; z += s[i] - '0'; z %= MOD; } this->x = z; } mint& operator+=(const mint &a) { if ((x += a.x) >= MOD) x -= MOD; return *this; } mint& operator-=(const mint &a) { if ((x += MOD - a.x) >= MOD) x -= MOD; return *this; } mint& operator*=(const mint &a) { (x *= a.x) %= MOD; return *this; } mint& operator/=(const mint &a) { long long n = MOD - 2; mint u = 1, b = a; while (n > 0) { if (n & 1) { u *= b; } b *= b; n >>= 1; } return *this *= u; } mint operator+(const mint &a) const { mint res(*this); return res += a; } mint operator-(const mint &a) const { mint res(*this); return res -= a; } mint operator*(const mint &a) const { mint res(*this); return res *= a; } mint operator/(const mint &a) const { mint res(*this); return res /= a; } friend std::ostream& operator<<(std::ostream &os, const mint &n) { return os << n.x; } bool operator==(const mint &a) const { return this->x == a.x; } }; int main() { int n,m;cin >> n >> m; if (n > m) { puts("1"); return 0; } if (n == 1) { cout << 1 << endl; return 0; } else { vector<mint> dp(m+1,0); dp[0] = 1; for (int i = 0; i < m; i++) { dp[i + 1] = dp[i]; if (i + 1 - n >= 0) dp[i + 1] += dp[i + 1 - n]; } cout << dp[m] << endl; } return 0; }