結果
問題 | No.420 mod2漸化式 |
ユーザー |
👑 |
提出日時 | 2019-05-02 00:53:49 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,001 bytes |
コンパイル時間 | 810 ms |
コンパイル使用メモリ | 72,636 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-31 12:48:21 |
合計ジャッジ時間 | 1,993 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 |
ソースコード
#include <cstdio>#include <cstdlib>#include <cstddef>#include <vector>#include <algorithm>#include <cmath>#include <string>#include <iostream>#include <iomanip>#define L64 long long#define MOD (1000000007LL)L64 modpow(L64 src, L64 pow, L64 mod){L64 res = 1;while (0 < pow) {if (pow % 2 == 1) {res = (res * src) % mod;pow--;}src = (src * src) % mod;pow /= 2;}return res;}L64 modinv(L64 src, L64 mod){return modpow(src, mod - 2, mod);}L64 getConv(L64 n, L64 k, L64 mod){L64 ret = 1;for (L64 i = 1; i <= k; i++) {ret = (ret * (n + 1 - i)) % mod;ret = (ret * modinv(i, mod)) % mod;}return ret;}int main(void){L64 x;std::cin >> x;if(x == 0){std::cout << "1 0" << std::endl;return 0;}else if(32 <= x){std::cout << "0 0" << std::endl;return 0;}L64 a = getConv(31LL, x, MOD);L64 b = 2147483647LL * getConv(30LL, x - 1, MOD);std::cout << a << " " << b << std::endl;}