結果

問題 No.492 IOI数列
ユーザー le_panda_noirle_panda_noir
提出日時 2020-04-11 14:30:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,644 bytes
コンパイル時間 845 ms
コンパイル使用メモリ 80,608 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-19 04:36:56
合計ジャッジ時間 1,674 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;
using ll = long long;
template<class T>using vv = vector<vector<T>>;

#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0;i<(n);++i)

template<int MOD> struct MInt {
  long long val;
  MInt(long long val = 0) : val(val % MOD) { if (val < 0) val += MOD; }
  MInt operator-() const { return MInt(-val); }
  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) 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 = (MOD + val - n.val) % MOD; return *this; }
  MInt& operator*=(const MInt& n) { val = (val * n.val) % MOD; return *this; }
  MInt& operator/=(const MInt& n) { val = (*this * n.inv()).val; return *this; }
  bool operator==(const MInt& n) { return val == n.val; }
  bool operator!=(const MInt& n) { return val != n.val; }
  MInt inv() const {
    MInt pow = val, ans = 1;
    for (int p = MOD - 2; p > 0; p >>= 1) {
      if (p & 1) ans *= pow;
      pow *= pow;
    }
    return ans;
  }
  friend ostream& operator<<(ostream& os, const MInt& n) { os<<n.val; return os; }
  friend istream& operator>>(istream& os, MInt& n) { os>>n.val; return os; }
};
const int MOD = 1e9+7;
using mint = MInt<MOD>;

template<class T> struct Matrix {
  vector<vector<T>> val;
  Matrix(vector<vector<T>> val = {{1, 0}, {0, 1}}) : val(val) {};
  Matrix operator+(const Matrix& n) const { return Matrix(val) += n; }
  Matrix operator*(const Matrix& n) const { return Matrix(val) *= n; }
  Matrix& operator+=(const Matrix& n) {
    val[0][0] += n.val[0][0]; val[0][1] += n.val[0][1]; val[1][0] += n.val[1][0]; val[1][1] += n.val[1][1];
    return *this;
  }
  Matrix& operator*=(const Matrix& n) {
    T a = val[0][0] * n.val[0][0] + val[0][1] * n.val[1][0],
      b = val[0][0] * n.val[0][1] + val[0][1] * n.val[1][1],
      c = val[1][0] * n.val[0][0] + val[1][1] * n.val[1][0],
      d = val[1][0] * n.val[0][1] + val[1][1] * n.val[1][1];
    val[0][0] = a; val[0][1] = b; val[1][0] = c; val[1][1] = d;
    return *this;
  }
  Matrix pow(ll N) {
    Matrix pow = val, ans;
    for (ll p = N; p > 0; p >>= 1) {
      if (p & 1) ans *= pow;
      pow *= pow;
    }
    return ans;
  }
};

int main() {
  ll in(N);

  Matrix ans = vv<mint>{{100, 1}, {0, 1}};
  ans = ans.pow(N-1);
  cout << ans.val[0][0] + ans.val[0][1] << endl;

  cout << 1;
  rep(i, (N-1) % 11) {
    cout << "01";
  }
  cout << endl;

  return 0;
}
0