結果

問題 No.906 Y字グラフ
ユーザー le_panda_noir
提出日時 2020-04-26 17:30:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 708 bytes
コンパイル時間 585 ms
コンパイル使用メモリ 66,468 KB
最終ジャッジ日時 2025-01-10 01:59:49
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#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