結果

問題 No.906 Y字グラフ
ユーザー KKT89
提出日時 2019-10-12 14:40:23
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 68,480 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 22:32:00
合計ジャッジ時間 1,554 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

ll mod=1e9+7;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n; cin >> n;
	n-=4;
	ll ans=0;
	if(n%6==0){
		ll m=n/6;
		m%=mod;
		ans+=3*m*m%mod;
		ans+=3*m%mod;
		ans++;
		ans%=mod;
	}
	else{
		ll m=n/6;
		m%=mod;
		ll k=n%6;
		ans=(3*m+k)%mod*(m+1)%mod;
	}
	cout << ans << endl;
}
0