結果
| 問題 | No.793 うし数列 2 | 
| コンテスト | |
| ユーザー |  mhrb_minase | 
| 提出日時 | 2019-02-22 21:57:14 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 1,426 bytes | 
| コンパイル時間 | 1,502 ms | 
| コンパイル使用メモリ | 166,964 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-25 08:09:10 | 
| 合計ジャッジ時間 | 2,158 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 21 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;
long long power(long long x, long long n){
    long long res = 1;
    x %= MOD;
    while(n > 0LL){
        if(n & 1LL){
            res *= x;
            res %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;
    }
    return res;
}
long long moddiff(long long a, long long b){
    long long res = a - b;
    if(res < 0LL){
        long long t = (abs(res) - 1LL) / MOD + 1LL;
        res += MOD * t;
    }
    res %= MOD;
    return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    lint ans = 40LL * power(10, n - 1LL);
    ans %= MOD;
    ans = moddiff(ans, 1);
    ans *= power(3, MOD - 2);
    ans %= MOD;
    cout << ans << endl;
    return 0;
}
            
            
            
        