結果
問題 | No.492 IOI数列 |
ユーザー |
|
提出日時 | 2017-03-13 18:45:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 814 bytes |
コンパイル時間 | 1,684 ms |
コンパイル使用メモリ | 176,304 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-30 00:39:14 |
合計ジャッジ時間 | 2,398 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include<bits/stdc++.h> #define MOD 1000000007 #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef long long ll; typedef vector<ll>vec; typedef vector<vec>mat; mat mul(mat&a, mat&b) { mat c(a.size(), vec(b[0].size())); rep(i, a.size())rep(j, b[0].size())rep(k, b.size()) (c[i][j] += a[i][k] * b[k][j]) %= MOD; return c; } mat ppow(mat&a, ll b) { mat res(a.size(), vec(a.size())); rep(i, a.size())res[i][i] = 1; while (b) { if (b & 1)res = mul(res, a); a = mul(a, a); b >>= 1; } return res; } string s[]{ "1","101","10101","1010101","101010101","10101010101","1010101010101","101010101010101","10101010101010101","1010101010101010101","0" }; int main() { ll n; scanf("%lld", &n); mat a{ {100,1},{0,1} }; a = ppow(a, n); cout << a[0][1] << endl; cout << s[(n-1) % 11] << endl; }