Submission #00196
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | #include <bits/stdc++.h> using namespace std; //#include <boost/multiprecision/cpp_int.hpp> // using namespace boost::multiprecision; // using cint = cpp_int; //#pragma GCC optimize("", on) //#pragma GCC optimization_level 3 // Define using ll = long long ; using ull = unsigned long long ; using ld = long double ; const ll MOD = 1e9 + 7; const ll INF = LONG_MAX; const ull MAX = ULONG_MAX; #define mp make_pair #define pb push_back #define eb emplace_back #define x first #define y second #define endl '\n' #define space ' ' #define def inline auto #define func inline constexpr ll #define run __attribute__((constructor)) def _ #define all(v) begin(v), end(v) #define input(a) scanf("%lld", &(a)) #define print(a) printf("%lld\n", (a)) // Debug #define debug(...) \ { \ cerr << __LINE__ << ": " << #__VA_ARGS__ << " = " ; \ for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] " ; \ cerr << endl; \ } #define dump(a, h, w) \ { \ cerr << __LINE__ << ": " << #a << " = [" << endl; \ rep(i, h) { \ rep(j, w) cerr << a[i][j] << space; \ cerr << endl; \ } \ cerr << "]" << endl; \ } #define vdump(a, n) \ { \ cerr << __LINE__ << ": " << #a << " = [" ; \ rep(i, n) if (i) cerr << space << a[i]; \ else cerr << a[i]; \ cerr << "]" << endl; \ } // Loop #define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i) #define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i) #define each(i, a) for (auto &&i : a) #define rep(i, n) inc(i, 0, n - 1) #define loop() for (;;) // Stream #define fout(n) cout << fixed << setprecision(n) #define fasten cin.tie(0), ios::sync_with_stdio(0) // Speed run() { fasten, fout(10); } #pragma GCC optimize("O3") #pragma GCC target("avx") // Math func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } func lcm(ll a, ll b) { return a * b / gcd(a, b); } func sign(ll a) { return a ? abs (a) / a : 0; } def in() { ll A; cin >> A; return A; } def mod_pow(ll a, ll b) { if (b == 0) return 1LL; if (b & 1) return a * mod_pow(a, b - 1) % MOD; ll half = mod_pow(a, b / 2); return half * half % MOD; } def mod_comb(ll n, ll r) { r = min(r, n - r); ll sup = 1, sub = 1; rep(i, r) { sup *= n - i, sub *= i + 1; sup %= MOD, sub %= MOD; } return sup * mod_pow(sub, MOD - 2) % MOD; } ll W, H, N, X[101], Y[101], res = 1; signed main() { cin >> W >> H >> N; rep(i, N) { cin >> X[i] >> Y[i]; } X[N] = W - 1, Y[N] = H - 1; dec(i, N, 1) { X[i] -= X[i - 1], Y[i] -= Y[i - 1]; } rep(i, N + 1) { res *= mod_comb(X[i] + Y[i], X[i]); res %= MOD; } cout << res << endl; } // for compilation: g++ -Ofast -march=native -o _ _.cpp -std=c++17 |
ステータス
項目 | データ |
---|---|
問題 | 0006 - 寄り道 |
ユーザー名 | Shuzaei |
投稿日時 | 2018-11-24 15:22:11 |
言語 | C++17 |
状態 | Accepted |
得点 | 400 |
ソースコード長 | 3851 Byte |
最大実行時間 | 34 ms |
最大メモリ使用量 | 672 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 400 / 400 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
input01.in | AC | 23 ms | 604 KB |
1
|
input02.in | AC | 22 ms | 432 KB |
1
|
input03.in | AC | 26 ms | 516 KB |
1
|
input04.in | AC | 25 ms | 472 KB |
1
|
input05.in | AC | 18 ms | 560 KB |
1
|
input06.in | AC | 22 ms | 516 KB |
1
|
input07.in | AC | 33 ms | 472 KB |
1
|
input08.in | AC | 29 ms | 428 KB |
1
|
input09.in | AC | 23 ms | 512 KB |
1
|
input10.in | AC | 20 ms | 592 KB |
1
|
input11.in | AC | 21 ms | 540 KB |
1
|
input12.in | AC | 22 ms | 620 KB |
1
|
input13.in | AC | 21 ms | 572 KB |
1
|
input14.in | AC | 24 ms | 652 KB |
1
|
input15.in | AC | 34 ms | 476 KB |
1
|
input16.in | AC | 32 ms | 564 KB |
1
|
input17.in | AC | 23 ms | 640 KB |
1
|
input18.in | AC | 27 ms | 596 KB |
1
|
input19.in | AC | 24 ms | 672 KB |
1
|
input20.in | AC | 26 ms | 628 KB |
1
|
sample.in | AC | 26 ms | 576 KB |
1
|