結果
| 問題 |
No.269 見栄っ張りの募金活動
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-27 08:14:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 4,987 bytes |
| コンパイル時間 | 656 ms |
| コンパイル使用メモリ | 88,432 KB |
| 最終ジャッジ日時 | 2024-11-15 00:57:58 |
| 合計ジャッジ時間 | 1,115 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:32:33: error: 'numeric_limits' is not a member of 'std'
32 | static const int MAX_INT = std::numeric_limits<int>::max(); // 2147483647 = 2^31-1
| ^~~~~~~~~~~~~~
main.cpp:32:48: error: expected primary-expression before 'int'
32 | static const int MAX_INT = std::numeric_limits<int>::max(); // 2147483647 = 2^31-1
| ^~~
main.cpp:33:33: error: 'numeric_limits' is not a member of 'std'
33 | static const ll MAX_LL = std::numeric_limits<long long>::max();
| ^~~~~~~~~~~~~~
main.cpp:33:48: error: expected primary-expression before 'long'
33 | static const ll MAX_LL = std::numeric_limits<long long>::max();
| ^~~~
ソースコード
#include <iostream>
#include <iomanip>
#include <assert.h>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef std::pair<long long, long long> Pll;
typedef std::vector<int> vi;
typedef std::vector<long long> vl;
typedef std::vector<std::string> vs;
typedef std::vector<std::pair<long long, long long>> vpll;
typedef std::vector<std::vector<ll>> vvl;
template<class T> using V = std::vector<T>;
template<class T> using VV = std::vector<std::vector<T>>;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
static const int MAX_INT = std::numeric_limits<int>::max(); // 2147483647 = 2^31-1
static const ll MAX_LL = std::numeric_limits<long long>::max();
static const int INF = (1 << 29); // cf) INT_MAX = 2147483647 = 2^31-1
static const ll INFLL = (1ll << 61); // cf) LLONG_MAX = 9223372036854775807 = 2^63 - 1
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define rrep(i,n) RREP(i,0,n)
#define RREP(i,x,n) for(ll i=(ll)(n)-1ll;i>=(ll)(x);--i)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define SUM(x) accumulate(ALL(x), 0ll)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// change min/max
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
struct mint {
int mod;
ll x; // typedef long long ll;
mint(ll _x = 0, int _mod = 1000000007) :mod(_mod), x((_x%_mod + _mod) % _mod) {}
mint operator-() const { return mint(-x, mod); }
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) const { return mint(*this) += a; }
mint operator-(const mint a) const { return mint(*this) -= a; }
mint operator*(const mint a) const { return mint(*this) *= a; }
mint pow(ll t) const {
if (!t) return mint(1, mod);
mint a = pow(t >> 1);
a *= a;
if (t & 1) a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint& operator=(const mint& rhs) {
if (this == &rhs) return *this;
x = rhs.x;
mod = rhs.mod;
return *this;
}
mint& operator/=(const mint a) { return *this *= a.inv(); }
mint operator/(const mint a) const { return mint(*this) /= a; }
};
std::istream& operator>>(std::istream& is, mint& a) { return is >> a.x; }
std::ostream& operator<<(std::ostream& os, const mint& a) { return os << a.x; }
//void Main() {
// ll N, S, K; cin >> N >> S >> K;
//
// vector<vector<mint>> dp(N + 10, vector<mint>(S + 10, 0));
// // vector<vector<ll>> dp(N + 2, vector<ll>(S + 2, 0));
//
// dp[0][0] = 1;
//
// REP(i, 1, N + 1) {
// rep(j, S + 1) {
// ll sum = (i - 1) * i / 2 * K;
// if (sum > j) {
// dp[i][j] = 0;
// }
// else if (sum == j) {
// dp[i][j] = 1;
// }
// else{
// dp[i][j] = dp[i-1][j];
// int k = i - 2;
// while (k >= 0) {
// dp[i][j] -= dp[k][j];
// --k;
// }
//
// if (j - i >= 0) {
// dp[i][j] += dp[i][j-i];
// }
// }
// }
// }
//
// cout << dp[N][S] << endl;
//}
//void Main() {
// ll N, S, K; cin >> N >> S >> K;
//
// vector<vector<mint>> dp(N + 10, vector<mint>(S + 10, 0));
//
// dp[0][0] = 1;
//
// REP(i, 1, N + 1) {
// rep(j, S + 1) {
// if (j - (N - i) >= 0) {
// dp[i][j] += dp[i][j - (N - i)];
// }
// if (j - K * (N - i) >= 0) {
// dp[i][j] += dp[i-1][j - K * (N - i)];
// }
// }
// }
//
// cout << dp[N][S] << endl;
//}
void Main() {
ll N, S, K; cin >> N >> S >> K;
vector<vector<mint>> dp(N + 10, vector<mint>(S + 10, 0));
dp[0][0] = 1;
S -= (N - 1) * N / 2 * K;
if (S < 0) {
cout << 0 << endl;
return;
}
REP(i, 1, N + 1) {
rep(j, S + 1) {
dp[i][j] = dp[i-1][j];
if (j - i >= 0) {
dp[i][j] += dp[i][j-i];
}
}
}
cout << dp[N][S] << endl;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout << std::fixed << std::setprecision(15);
Main();
double tmp;
cin >> tmp;
return 0;
}