結果

問題 No.793 うし数列 2
ユーザー 👑 emthrmemthrm
提出日時 2019-02-23 02:56:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,569 bytes
コンパイル時間 1,105 ms
コンパイル使用メモリ 121,604 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 06:07:04
合計ジャッジ時間 2,337 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
long long mod_pow(long long base, long long exponent) {
  long long res = 1;
  while (exponent > 0) {
    if (exponent & 1) (res *= base) %= MOD;
    (base *= base) %= MOD;
    exponent >>= 1;
  }
  return res;
}

pair<long long, long long> ext_gcd(long long a, long long b) {
  if (b == 0) return {1, 0};
  pair<long long, long long> pr = ext_gcd(b, a % b);
  return {pr.second, pr.first - a / b * pr.second};
}

long long mod_inv(long long a) {
  if (__gcd(a, (long long)MOD) != 1) return 0;
  pair<long long, long long> pr = ext_gcd(a, MOD);
  return (pr.first + MOD) % MOD;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  long long n; cin >> n;
  long long tmp = mod_pow(10, n-1);
  long long ans = (tmp - 1 + MOD) % MOD * mod_inv(3) % MOD;
  (ans += tmp * 13 % MOD) %= MOD;
  cout << ans << '\n';
  return 0;
}
0