結果

問題 No.793 うし数列 2
ユーザー yuppe19 😺yuppe19 😺
提出日時 2019-02-22 21:44:23
言語 Python2
(2.7.18)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 558 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 7,076 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-04 00:59:48
合計ジャッジ時間 1,501 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#!/usr/bin/python2
# -*- coding: utf-8 -*-
# †
mod = 10**9 + 7

def mod_inv(a, m):
    b, s, t, old_a = m, 1, 0, a
    while b:
        q = a / b
        a %= b
        a, b = b, a
        s -= t * q
        s, t = t, s
    if a != 1:
        return None
    return s + m if s < 0 else s


# \frac{10^{n} - 1}{3} + 10^{n}
def f(n):
    inv = mod_inv(3, mod)
    p10 = pow(10, n, mod)
    res = (p10 - 1) * inv + p10
#    res = (p10 - 1) / 3 + p10 # わざと 3 で割ってみる
    res %= mod
    return res

##
N = int(raw_input())
res = f(N)
print res
0