結果
| 問題 |
No.269 見栄っ張りの募金活動
|
| ユーザー |
yna
|
| 提出日時 | 2020-02-20 08:58:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 5,000 ms |
| コード長 | 2,719 bytes |
| コンパイル時間 | 1,911 ms |
| コンパイル使用メモリ | 167,612 KB |
| 実行使用メモリ | 11,512 KB |
| 最終ジャッジ日時 | 2024-10-08 18:43:27 |
| 合計ジャッジ時間 | 2,919 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
// fatorial.cpp depend on this.
#ifndef MOD_INT
#define MOD_INT
template<int mod>
struct ModInt{
private:
int x;
public:
ModInt() : x(0){}
ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod){}
ModInt &operator+=(const ModInt &p){
if((x += p.x) >= mod) x -= mod;
return *this;
}
ModInt &operator-=(const ModInt &p){
if((x += mod - p.x) >= mod) x -= mod;
return *this;
}
ModInt &operator*=(const ModInt &p){
x = (int) (1LL * x * p.x % mod);
return *this;
}
ModInt &operator/=(const ModInt &p){
*this *= p.inverse();
return *this;
}
ModInt operator-() const {return ModInt(-x);}
ModInt operator+(const ModInt &p) const {return ModInt(*this) += p;}
ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p;}
ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p;}
ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p;}
bool operator==(const ModInt &p) const {return x == p.x;}
bool operator!=(const ModInt &p) const {return x != p.x;}
bool operator<(const ModInt &p) const {return x < p.x;}
void operator=(const int &p){x = p >= 0 ? p % mod : (mod - (-p) % mod) % mod;}
template<typename T>
operator T() const {return (T)x;}
ModInt inverse() const {
int a = x, b = mod, u = 1, v = 0, t;
while(b > 0) {
t = a / b;
swap(a -= t * b, b);
swap(u -= t * v, v);
}
return ModInt(u);
}
ModInt pow(int64_t n) const {
ModInt ret(1), mul(x);
while(n > 0) {
if(n & 1) ret *= mul;
mul *= mul;
n >>= 1;
}
return ret;
}
friend ostream &operator<<(ostream &os, const ModInt &p){
return os << p.x;
}
friend istream &operator>>(istream &is, ModInt &a){
int64_t t;
is >> t;
a = ModInt< mod >(t);
return (is);
}
static int get_mod(){return mod;}
};
using mint = ModInt<MOD>;
#endif
mint dp[20001][101];
int N, S, K;
int main(void){
cin >> N >> S >> K;
int M = S - N * (N-1) * K / 2;
for(int i = 0; i <= M; i++){
for(int j = 0; j <= N; j++){
dp[i][j] = 0;
}
}
if(M < 0){
cout << "0\n";
return 0;
}
dp[0][0] = 1;
for(int j = 0; j <= N; j++){
for(int i = 0; i <= M; i++){
if(j-1 >= 0) dp[i][j] += dp[i][j-1];
if(i-j >= 0 and i != 0) dp[i][j] += dp[i-j][j];
// printf("dp(%d, %d) = ", i, j);
// cout << dp[i][j] << '\n';
}
}
cout << dp[M][N] << '\n';
return 0;
}
yna