結果
| 問題 |
No.420 mod2漸化式
|
| ユーザー |
kyo1
|
| 提出日時 | 2021-01-05 17:43:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 797 bytes |
| コンパイル時間 | 2,479 ms |
| コンパイル使用メモリ | 192,384 KB |
| 最終ジャッジ日時 | 2025-01-17 09:47:34 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 15 WA * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int64_t comb(int n, int r) {
int64_t res = 1;
for (int i = 0; i < r; i++) {
res *= n - i;
}
for (int j = 1; j < r + 1; j++) {
res /= j;
}
return res;
}
template <typename T>
int64_t pow(int64_t x, T n, int64_t mod = std::numeric_limits<int64_t>::max()) {
int64_t res = 1;
while (n > 0) {
if (n & 1) res = static_cast<__int128>(res) * static_cast<__int128>(x) % mod;
x = static_cast<__int128>(x) * static_cast<__int128>(x) % mod;
n >>= 1;
}
return res;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int x;
cin >> x;
if (x <= 31) {
cout << comb(31, x) << ' ' << (pow(INT64_C(2), 31) - 1) * comb(30, x - 1) << '\n';
} else {
cout << 0 << ' ' << 0 << '\n';
}
return 0;
}
kyo1