結果
| 問題 |
No.1186 長方形の敷き詰め
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-22 14:13:46 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,828 bytes |
| コンパイル時間 | 2,610 ms |
| コンパイル使用メモリ | 139,148 KB |
| 実行使用メモリ | 18,848 KB |
| 最終ジャッジ日時 | 2024-10-15 08:28:33 |
| 合計ジャッジ時間 | 2,798 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 WA * 2 |
ソースコード
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>
using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
using int64 = long long;
const int MOD = 1000000007;
class mint {
using int64 = long long;
private:
int64 x;
public:
mint(const int64 x1=0) { x = x1%MOD; };
mint& operator++(int n) { x+=1; return *this; };
mint& operator--(int n) { x-=1; return *this; };
mint& operator=(int64 n) { x=n%MOD; return *this; };
mint& operator--() {x-=1; return *this; };
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) { return (*this) *= a.inv();}
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; }
mint inv() const { return pow(MOD-2);}
friend ostream& operator<<(ostream &os, const mint a) noexcept { return os << a.x; }
constexpr bool operator == (const mint& r) const noexcept { return this->x == r.x; }
constexpr bool operator != (const mint& r) const noexcept { return this->x != r.x; }
mint pow(long long t) const {
if (!t) return mint(1);
mint a = pow(t>>1);
a*=a;
if(t&1) a*= *this;
return a;
}
};
struct combination {
vector<mint> fact, ifact;
// コンストラクタ
combination(int n):fact(n+1),ifact(n+1) {
fact[0] = mint(1);
for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*mint(i);
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*mint(i);
}
mint nCr(int n, int r) {
if (r < 0 || r > n) return 0;
return fact[n]*ifact[r]*ifact[n-r];
}
mint nPr(int n, int r) {
if (r < 0 || r > n) return 0;
return fact[n]*ifact[n-r];
}
} comb(1000005);
int main() {
int64 n,m;
cin >> n >> m;
if (n==1) {
cout << 1 << endl;
return 0;
}
mint ans = 1;
for (int64 i=1; i<=m/n; i++) {
int64 rest = m - i*n;
ans += comb.nCr(rest + i, i);
}
cout << ans << endl;
}