結果
問題 | No.906 Y字グラフ |
ユーザー |
|
提出日時 | 2019-10-11 21:52:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 778 bytes |
コンパイル時間 | 1,654 ms |
コンパイル使用メモリ | 166,968 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-25 07:15:53 |
合計ジャッジ時間 | 2,607 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;const ll MOD = 1000000007;ll modpow(ll x, ll n, ll mod = MOD) {ll res = 1;while (n > 0) {if (n & 1) res = res * x % mod;x = x * x % mod;n >>= 1;}return res;}int main() {cin.tie(0);ios::sync_with_stdio(false);ll n;cin >> n;n -= 4;ll total = (n + 2) % MOD * ((n + 1) % MOD) % MOD * ((MOD + 1) / 2) % MOD;ll ans = 0;if (n % 3 == 0) {ans++;total = (total + MOD - 1) % MOD;}ll hoge = (n / 2 + 1 - (n % 3 == 0)) % MOD;(ans += hoge) %= MOD;total = (total + MOD - hoge * 3 % MOD) % MOD;(ans += total * modpow(6, MOD - 2) % MOD) %= MOD;cout << ans << "\n";return 0;}