結果
| 問題 |
No.906 Y字グラフ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-11 23:29:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 2,176 bytes |
| コンパイル時間 | 1,163 ms |
| コンパイル使用メモリ | 159,736 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-25 09:58:09 |
| 合計ジャッジ時間 | 2,014 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 28 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
struct FastIO{
FastIO(){
cin.tie(0);
ios::sync_with_stdio(0);
}
}fastio_beet;
template<typename T,T MOD = 1000000007>
struct Mint{
static constexpr T mod = MOD;
T v;
Mint():v(0){}
Mint(signed v):v(v){}
Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}
Mint pow(long long k){
Mint res(1),tmp(v);
while(k){
if(k&1) res*=tmp;
tmp*=tmp;
k>>=1;
}
return res;
}
static Mint add_identity(){return Mint(0);}
static Mint mul_identity(){return Mint(1);}
Mint inv(){return pow(MOD-2);}
Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
Mint& operator/=(Mint a){return (*this)*=a.inv();}
Mint operator+(Mint a) const{return Mint(v)+=a;};
Mint operator-(Mint a) const{return Mint(v)-=a;};
Mint operator*(Mint a) const{return Mint(v)*=a;};
Mint operator/(Mint a) const{return Mint(v)/=a;};
Mint operator-() const{return v?Mint(MOD-v):Mint(v);}
bool operator==(const Mint a)const{return v==a.v;}
bool operator!=(const Mint a)const{return v!=a.v;}
bool operator <(const Mint a)const{return v <a.v;}
static Mint comb(long long n,Int k){
Mint num(1),dom(1);
for(Int i=0;i<k;i++){
num*=Mint(n-i);
dom*=Mint(i+1);
}
return num/dom;
}
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}
//INSERT ABOVE HERE
signed main(){
Int n;
cin>>n;
n-=4;
using M = Mint<Int>;
M ans{0};
// x = y = z
if(n%3==0) ans+=M(1);
// x = y, x != z
ans+=M(n/2+1)-M(n%3==0);
M res{1};
res*=M(n+2);
res*=M(n+1);
res/=M(1);
res/=M(2);
//cout<<res<<endl;
if(n%3==0) res-=M(1);
res-=(M(n/2+1)-M(n%3==0))*M(3);
//cout<<res<<endl;
res/=M(6);
ans+=res;
cout<<ans<<endl;
return 0;
}