結果
| 問題 |
No.793 うし数列 2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-03 04:02:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 800 bytes |
| コンパイル時間 | 2,203 ms |
| コンパイル使用メモリ | 194,276 KB |
| 最終ジャッジ日時 | 2025-01-06 21:54:03 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
ソースコード
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long power(long long x, long long y) {
long long res = 1;
while (y) {
if (y & 1) res = res * x % mod;
x *= x;
res %= mod;
x %= mod;
y >>= 1;
}
return res;
}
long long sub(long long x, long long y) {
long long res = x - y;
if (x < 0) x += mod;
return res;
}
long long inverse(long long x) {
x = (x % mod + mod) % mod;
long long y = mod, u = 1, v = 0;
while(y) {
long long t = x / y;
x -= t * y; swap(x, y);
u -= t * v; swap(u, v);
}
return (u % mod + mod) % mod;
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
long long n;
cin >> n;
cout << sub(4 * power(10, n) % mod, 1) * inverse(3) % mod << endl;
return 0;
}