結果
| 問題 | No.492 IOI数列 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-04-01 20:30:52 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 1,000 ms | 
| コード長 | 1,736 bytes | 
| コンパイル時間 | 970 ms | 
| コンパイル使用メモリ | 109,460 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-07 19:02:11 | 
| 合計ジャッジ時間 | 1,801 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
ソースコード
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;
const int MOD = 1000000007;
// 行列の積
template <class T>
vector<vector<T> > matrixProduct(const vector<vector<T> >& x, const vector<vector<T> >& y)
{
    int a = x.size();
    int b = x[0].size();
    int c = y[0].size();
    vector<vector<T> > z(a, vector<T>(c, 0));
    for(int i=0; i<a; ++i){
        for(int j=0; j<c; ++j){
            for(int k=0; k<b; ++k){
                z[i][j] += x[i][k] * y[k][j];
                z[i][j] %= MOD;
            }
        }
    }
    return z;
}
// 行列の累乗
template <class T>
vector<vector<T> > matrixPower(const vector<vector<T> >& x, long long k)
{
    int n = x.size();
    vector<vector<T> > y(n, vector<T>(n, 0));
    for(int i=0; i<n; ++i)
        y[i][i] = 1; // 積の単位元
    vector<vector<T> > z = x;
    while(k > 0){
        if(k & 1)
            y = matrixProduct(y, z);
        z = matrixProduct(z, z);
        k >>= 1;
    }
    return y;
}
int main()
{
    long long n;
    cin >> n;
    vector<vector<long long> > mat = {{100, 1}, {0, 1}};
    mat = matrixPower(mat, n);
    cout << mat[0][1] << endl;
    int a = n % 11;
    string s;
    if(a == 0){
        s = "0";
    }
    else{
        s = "1";
        for(int i=1; i<a; ++i)
            s += "01";
    }
    cout << s << endl;
    return 0;
}
            
            
            
        