結果

問題 No.793 うし数列 2
ユーザー yuppe19 😺
提出日時 2019-02-22 21:43:43
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 558 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-25 06:43:29
合計ジャッジ時間 1,586 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 8 WA * 13
権限があれば一括ダウンロードができます

ソースコード

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