結果

問題 No.906 Y字グラフ
コンテスト
ユーザー le_panda_noir
提出日時 2020-04-26 17:30:16
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 708 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 463 ms
コンパイル使用メモリ 80,660 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-09 19:15:12
合計ジャッジ時間 2,419 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
using namespace std;
template<int MOD> struct MInt {
  long long val;
  MInt(long long val) : val(val % MOD) {}
  MInt operator+(const MInt& n) const { return MInt(val) += n; }
  MInt operator*(const MInt& n) const { return MInt(val) *= n; }
  MInt& operator+=(const MInt& n) { val = (val + n.val) % MOD; return *this; }
  MInt& operator*=(const MInt& n) { val = (val * n.val) % MOD; return *this; }
  friend ostream& operator<<(ostream& os, const MInt& n) { os<<n.val; return os; }
};
using mint = MInt<1000000007>;
int main() {
  long long N; cin >> N; N -= 4;
  long long n = N / 6;
  mint ans = mint(n+1) * mint(3 * n + (N % 6));
  cout << ans + (N % 6 == 0) << endl;
    return 0;
}
0