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