結果
| 問題 |
No.117 組み合わせの数
|
| ユーザー |
sugim48
|
| 提出日時 | 2015-01-04 23:32:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,454 bytes |
| コンパイル時間 | 967 ms |
| コンパイル使用メモリ | 84,160 KB |
| 実行使用メモリ | 8,736 KB |
| 最終ジャッジ日時 | 2024-06-13 02:20:18 |
| 合計ジャッジ時間 | 2,187 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:70:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
70 | scanf("%c(%d,%d)", &c, &N, &K);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
ll extgcd(ll a, ll b, ll& x, ll& y) {
if (b == 0) {
x = (a >= 0) ? 1 : -1;
y = 0;
return abs(a);
}
else {
ll res = extgcd(b, a % b, y, x);
y -= (a / b) * x;
return res;
}
}
ll mod_inverse(ll a, ll m) {
ll x, y;
extgcd(a, m, x, y);
return (m + x % m) % m;
}
vector<int> f(1000001);
ll P(ll n, ll k) {
if (n < k) return 0;
return (f[n] * mod_inverse(f[n - k], MOD)) % MOD;
}
ll C(ll n, ll k) {
return (P(n, k) * mod_inverse(f[k], MOD)) % MOD;
}
int main() {
f[0] = 1;
for (int i = 1; i <= 1000000; i++)
f[i] = (f[i - 1] * i) % MOD;
int T; cin >> T; cin >> ws;
while (T--) {
char c; int N, K;
scanf("%c(%d,%d)", &c, &N, &K);
cin.ignore();
if (c == 'C') cout << C(N, K) << endl;
if (c == 'P') cout << P(N, K) << endl;
if (c == 'H') cout << C(N + K - 1, N - 1) << endl;
}
}
sugim48