結果
| 問題 |
No.793 うし数列 2
|
| コンテスト | |
| ユーザー |
lightning
|
| 提出日時 | 2019-03-20 09:10:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 2,566 bytes |
| コンパイル時間 | 1,667 ms |
| コンパイル使用メモリ | 169,904 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-16 07:40:31 |
| 合計ジャッジ時間 | 2,370 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
ソースコード
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return 1;}return 0;}
class Modulo{
public:
ll val;
static const ll mod = 1e9+7;
vector<ll> factable = {1};
vector<ll> invtable = {1};
ll pro(ll x,ll y){return ((x%mod)*(y%mod))%mod;}
ll sum(ll x,ll y){return ((x%mod)+(y%mod))%mod;}
ll dif(ll x,ll y){ll d =((x%mod)-(y%mod))%mod;if(d>=0){return d;}else{return d+mod;}}
ll quo(ll x, ll y){return pro(x,pow(y,mod-2));}
ll pow(ll x,ll y){
if(y<=0){return 1;}
if(y%2==0){ll d = pow(x,y/2);return ((d%mod)*(d%mod))%mod;}
else{return (x*pow(x,y-1))%mod;}
}
void operator=(ll n){this->val = n%mod;}
ll operator+(ll n){return sum(this->val,n);}
ll operator-(ll n){return dif(this->val,n);}
ll operator*(ll n){return pro(this->val,n);}
ll operator/(ll n){return quo(this->val,n);}
void operator+=(ll n){this->val = sum(this->val,n);}
void operator-=(ll n){this->val = dif(this->val,n);}
void operator*=(ll n){this->val = pro(this->val,n);}
void operator/=(ll n){this->val = quo(this->val,n);}
ll fac(ll x){
//x! mod mod
if(factable.size()<=x){
ll s = factable.size();
FOR(i,s,x+1){
factable.push_back(pro(i,factable.back()));
invtable.push_back(quo(1,factable.back()));
}
}
if(x<0) return 1;
else return factable[x];
}
ll facinv(ll x){
if(invtable.size()<=x){
ll s = invtable.size();
FOR(i,s,x+1){
factable.push_back(pro(i,factable.back()));
invtable.push_back(quo(1,factable.back()));
}
}
if(x<0) return 1;
else return invtable[x];
}
ll com(ll x,ll y){
//xCy mod mod = x!/((x-y)!*y!) mod mod
if(x-y<y)return com(x,x-y);
return pro(fac(x),pro(facinv(x-y),facinv(y)));
}
};
ll n;
Modulo m;
int main(){
cin >> n;
m=1;
m=4*m.pow(10,n)-1;
m/=3;
put(m.val);
return 0;
}
lightning