結果
問題 | No.420 mod2漸化式 |
ユーザー |
![]() |
提出日時 | 2021-01-05 17:52:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 837 bytes |
コンパイル時間 | 1,795 ms |
コンパイル使用メモリ | 192,028 KB |
最終ジャッジ日時 | 2025-01-17 09:48:01 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 |
ソースコード
#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;res /= i + 1;}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) {if (x == 0) {cout << 1 << ' ' << 0 << '\n';} else {cout << comb(31, x) << ' ' << (pow(INT64_C(2), 31) - 1) * comb(30, x - 1) << '\n';}} else {cout << 0 << ' ' << 0 << '\n';}return 0;}