結果

問題 No.420 mod2漸化式
ユーザー 👑 obakyanobakyan
提出日時 2019-05-02 00:53:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 937 bytes
コンパイル時間 932 ms
コンパイル使用メモリ 72,048 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 04:31:55
合計ジャッジ時間 2,644 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 || 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;
}
0