結果
| 問題 | 
                            No.1877 俺自身が線グラフになることだ
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-03-19 11:32:31 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 15 ms / 2,000 ms | 
| コード長 | 1,670 bytes | 
| コンパイル時間 | 2,151 ms | 
| コンパイル使用メモリ | 197,404 KB | 
| 最終ジャッジ日時 | 2025-01-28 10:44:48 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 12 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
constexpr int inf = 1e18;
constexpr int maxn = 2e5 + 5;
constexpr int mod = 998244353;
constexpr int P = 1000000007;
// assume -P <= x < 2P
int norm(int x) 
{
  if (x < 0) x += P;
  if (x >= P) x -= P;
  return x;
}
template<class T>
T qpow(T a, int b) 
{
  T res = 1;
  for (; b; b /= 2, a *= a) 
  {
    if (b % 2) res *= a;
  }
  return res;
}
struct Z
{
  int x;
  Z(int x = 0) : x(norm(x)){}
  int val()const{return x;}
  Z operator - ()const{return Z(norm(P - x));}
  Z inv()const {assert(x != 0); return qpow(*this, P - 2);}
  Z &operator *= (const Z &rhs){x = x * rhs.x % P; return *this;}
  Z &operator += (const Z &rhs){x = norm(x + rhs.x); return *this;}
  Z &operator -= (const Z &rhs){x = norm(x - rhs.x); return *this;}
  Z &operator /= (const Z &rhs){return *this *= rhs.inv();}
  friend Z operator * (const Z &lhs, const Z &rhs){Z ret = lhs; ret *= rhs; return ret;}
  friend Z operator + (const Z &lhs, const Z &rhs){Z ret = lhs; ret += rhs; return ret;}
  friend Z operator - (const Z &lhs, const Z &rhs){Z ret = lhs; ret -= rhs; return ret;}
  friend Z operator / (const Z &lhs, const Z &rhs){Z ret = lhs; ret /= rhs; return ret;}
};
inline void solve()
{
  int n; cin >> n;
  vector f(n + 1, vector<Z>(n + 1));
  f[0][0] = 1;
  for(int i = 1; i <= n; i ++)
  {
    for (int j = 0; j <= n; j ++)
    {
      f[i][j] = f[i - 1][j];
      if (j >= i && i >= 3)
      {
        f[i][j] += f[i][j - i];
      }
    }
  }
  cout << f[n][n].val() << "\n";
}
signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
  return 0;
}
/*
The details you should care:
*/