結果

問題 No.269 見栄っ張りの募金活動
ユーザー petite_prog
提出日時 2020-02-22 16:49:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 21 ms / 5,000 ms
コード長 3,931 bytes
コンパイル時間 2,031 ms
コンパイル使用メモリ 178,716 KB
実行使用メモリ 19,456 KB
最終ジャッジ日時 2024-10-09 17:28:23
合計ジャッジ時間 2,568 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

/*
   ∫ ∫ ∫
   
  _ 
 _   
______
 (´・ω・)ノ 
   |  /
   UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //使!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
int N = V.size();
REP(i,N){
os << V[i];
if (i!=N-1) os << " ";
}
os << "\n";
return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
os << "(";
os << P.first;
os << " , ";
os << P.second;
os << ")";
return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
auto it=S.begin();
while(it!=S.end()){
os << *it;
os << " ";
it++;
}
os << "\n";
return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
for(auto it=q.begin();it<q.end();it++){
os<<*it;
os<<" ";
}
os<<endl;
return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;
int64 pow(int a,int b,int mod){
vector<bool> bit;
for(b=b;b>0;b>>=1){
bit.push_back(b&1);
}
vector<int64> fac(bit.size()); fac[0] = a;
int64 res = 1;
for(int i=1;i<bit.size();i++){
fac[i] = (fac[i-1] * fac[i-1])%mod;
}
for(int i=0;i<bit.size();i++){
if(bit[i]) res*=fac[i];
res%=mod;
}
return res;
}
//mint
struct mint {
int64 x;
mint(int64 x=0):x((x+2*MOD)%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 {
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 pow(int64 t) const {
if (!t) return 1;
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 a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
ostream& operator<<(ostream& os, mint a){
os << a.x;
return os;
}
//12 nk
////
mint ball_10(int n,int r){
vector<vector<mint>> P(n+1,vector<mint>(r+1,0));
REP(j,r+1) P[0][j]=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=r;j++){
P[i][j] = P[i][j-1]; //0
if (i-j>=0) P[i][j] += P[i-j][j]; //0
}
}
return P[n][r];
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int64 N,S,K;
cin >> N >> S >> K;
S -= N*K*(N-1)/2;
if (S<0) {
cout << 0 << bn;
return 0;
}
auto ans = ball_10(S,N);
cout << ans << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0