Submission #1609273
Source Code Expand
#pragma region include #include <iostream> #include <iomanip> #include <stdio.h> #include <sstream> #include <algorithm> #include <iterator> #include <cmath> #include <complex> #include <string> #include <cstring> #include <vector> #include <tuple> #include <bitset> #include <queue> #include <complex> #include <set> #include <map> #include <stack> #include <list> #include <fstream> #include <random> //#include <time.h> #include <ctime> #pragma endregion //#include ///////// #define REP(i, x, n) for(int i = x; i < n; ++i) #define rep(i,n) REP(i,0,n) #define ALL(X) X.begin(), X.end() ///////// #pragma region typedef typedef long long LL; typedef long double LD; typedef unsigned long long ULL; typedef std::pair<LL,LL> PLL;// typedef std::pair<int,int> PII;// #pragma endregion //typedef ////定数 const int INF = (int)1e9; const LL MOD = (LL)1e9+7; const LL LINF = (LL)1e18+20; const LD PI = acos(-1.0); const double EPS = 1e-9; ///////// using namespace::std; void solve(){ LL a,b,c; cin >> a >> b >> c; /* if(a<=1000 && c<=1000 ){ vector< vector<LL> > dp(c+1,vector<LL>(a)); dp[0][0] = 1; for(int i=1;i<a;++i){ dp[0][i] = (dp[0][i-1]*b ) % MOD; } for(int j=1;j<=c;++j){ dp[j][0] = 1; } for(int j=1;j<=c;++j){ for(int i=1;i<a;++i){ dp[j][i] = (dp[j-1][i]+dp[j][i-1]); if( dp[j][i] >= MOD ){ dp[j][i] -= MOD; } } } cout << dp[c][a-1] << endl; }else */ if( a <= 100000 && c <= 100000 ){ vector<LL> fact(100001); fact[0] = 1; for(LL i=1;i<=100000;++i){ fact[i] = (fact[i-1]*i) % MOD; } /* k!の逆元は powMod(fact[k],MOD-2)で求める :フェルマーの小定理 */ LL ans = 0; for(LL i=0;i<a;++i){ //(c-1)+(a-i-1) C (c-1) LL n = (c-1)+(a-i-1); LL k = c-1;//固定値 LL res = (fact[n]*powMod(fact[n-k],MOD-2)) % MOD; res = (res * powMod(fact[k],MOD-2) ) % MOD; res = (res * powMod(b,i) ) % MOD; ans += res; if( ans >= MOD ){ ans -= MOD; } } cout << ans << endl; } } #pragma region main signed main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;//小数を10進数表示 cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別 solve(); } #pragma endregion //main()
Submission Info
Submission Time | |
---|---|
Task | F - Range Sum Queries |
User | akarin55 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2377 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘void solve()’: ./Main.cpp:93:44: error: ‘powMod’ was not declared in this scope LL res = (fact[n]*powMod(fact[n-k],MOD-2)) % MOD; ^