結果
問題 |
No.665 Bernoulli Bernoulli
|
ユーザー |
|
提出日時 | 2021-10-22 20:23:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 821 bytes |
コンパイル時間 | 3,644 ms |
コンパイル使用メモリ | 41,856 KB |
最終ジャッジ日時 | 2025-01-25 03:01:45 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | WA * 15 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:34:20: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘int’ [-Wformat=] 34 | printf("%lld", alt1[K-1]); | ~~~^ ~~~~~~~~~ | | | | | int | long long int | %d main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%lld %lld", &N, &K); | ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio> #include <algorithm> using namespace std; int const MOD = 1000000007; int const K_MAX = 10000; int mul_inv(int a, int b) { int b0 = b, t, q; int x0 = 0, x1 = 1; if (b == 1) return 1; while (a > 1) { q = a / b; t = b, b = a % b, a = t; t = x0, x0 = x1 - q * x0, x1 = t; } if (x1 < 0) x1 += b0; return x1; } int main() { long long int N, K; int _aa[2][K_MAX], *alt1 = _aa[0], *alt2 = _aa[1]; scanf("%lld %lld", &N, &K); alt1[0] = 1LL * N*(N+1)/2 % MOD; for(int i=1; i+1<=K; ++i) { alt2[0] = N; for(int j=1; j<=i+1; ++j) { alt2[0] = 1LL * alt2[0]*(N+j) % MOD; } alt2[0] = 1LL * alt2[0]*mul_inv(i+2, MOD) % MOD; for(int j=1; j<i+1; ++j) { alt2[j] = (alt2[j-1] - 1LL * alt1[j-1]*(i+1-j) % MOD + MOD) % MOD; } swap(alt1, alt2); } printf("%lld", alt1[K-1]); return 0; }