結果

問題 No.793 うし数列 2
ユーザー 👑 obakyan
提出日時 2019-04-20 09:47:58
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 729 bytes
コンパイル時間 1,526 ms
コンパイル使用メモリ 71,992 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-25 07:35:51
合計ジャッジ時間 1,617 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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);
}

int main(void)
{
  L64 n, res;
  std::cin >> n;
  res = 4LL;
  /* a[n]= (4 * 10^n - 1) / 3 */
  res = (res * modpow(10LL, n, MOD) - 1) % MOD;
  res = (res * modinv(3, MOD)) % MOD;
  std::cout << res << std::endl;
  return 0;
}
0