結果
問題 | No.834 Random Walk Trip |
ユーザー |
![]() |
提出日時 | 2019-05-25 00:32:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 609 ms / 2,000 ms |
コード長 | 2,020 bytes |
コンパイル時間 | 1,526 ms |
コンパイル使用メモリ | 169,228 KB |
実行使用メモリ | 19,328 KB |
最終ジャッジ日時 | 2024-09-17 12:55:18 |
合計ジャッジ時間 | 15,419 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
#include <bits/stdc++.h>using namespace std;//repetition#define FOR(i,a,b) for(ll i=(a);i<(b);++i)#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)//container util#define all(x) (x).begin(),(x).end()//typedeftypedef long long ll;typedef vector<int> VI;typedef vector<VI> VVI;typedef vector<ll> VLL;typedef vector<VLL> VVLL;typedef vector<string> VS;typedef pair<int, int> PII;typedef pair<ll, ll> PLL;//const valueconst ll MOD = 1e9 + 7;//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};//conversioninline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}ll mod = 1e9 + 7;//---------------------------------------------------------------------------------------------------ll f[1010101], rf[1010101];ll inv(ll x) {ll res = 1;ll k = mod - 2;ll y = x;while (k) {if (k & 1) res = (res * y) % mod;y = (y * y) % mod;k /= 2;}return res;}void init() {f[0] = 1;FOR(i, 1, 1010101) f[i] = (f[i - 1] * i) % mod;FOR(i, 0, 1010101) rf[i] = inv(f[i]);}//---------------------------------------------------------------------------------------------------ll modCombi(int n, int k) {ll a = f[n]; // = n!ll b = rf[n-k]; // = (n-k)!ll c = rf[k]; // = k!ll bc = (b * c) % mod;return (a * bc) % mod;}//---------------------------------------------------------------------------------------------------int main(void){ios::sync_with_stdio(false);cin.tie(0);ll n,k;cin >> n >> k;ll ans = 0;VLL array;if(n == 1){cout << 1 << endl;return 0;}init();for(int i= k / 2 % n; i <= k; i += n){ans+=modCombi(k, i);ans%=MOD;}cout << ans << endl;return 0;}