結果

問題 No.492 IOI数列
ユーザー outlineoutline
提出日時 2021-02-21 20:30:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,432 bytes
コンパイル時間 1,720 ms
コンパイル使用メモリ 141,256 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 21:58:12
合計ジャッジ時間 3,007 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
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 WA -
testcase_16 WA -
testcase_17 AC 2 ms
4,348 KB
testcase_18 WA -
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>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

struct mint {
    int x;
    mint() : x(0) {}
    mint(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    mint& operator+=(const mint& p){
        if((x += p.x) >= mod)   x -= mod;
        return *this;
    }
    mint& operator-=(const mint& p){
        if((x -= p.x) < 0)  x += mod;
        return *this;
    }
    mint& operator*=(const mint& p){
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    mint& operator/=(const mint& p){
        *this *= p.inverse();
        return *this;
    }
    mint operator-() const { return mint(-x); }
    mint operator+(const mint& p) const { return mint(*this) += p; }
    mint operator-(const mint& p) const { return mint(*this) -= p; }
    mint operator*(const mint& p) const { return mint(*this) *= p; }
    mint operator/(const mint& p) const { return mint(*this) /= p; }
    bool operator==(const mint& p) const { return x == p.x; }
    bool operator!=(const mint& p) const { return x != p.x; }
    mint pow(int64_t n) const {
        mint res = 1, mul = x;
        while(n > 0){
            if(n & 1)   res *= mul;
            mul *= mul;
            n >>= 1;
        }
        return res;
    }
    mint inverse() const { return pow(mod - 2); }
    friend ostream& operator<<(ostream& os, const mint& p){
        return os << p.x;
    }
    friend istream& operator>>(istream& is, mint& p){
        int64_t val;
        is >> val;
        p = mint(val);
        return is;
    }
};

using Vec = vector<mint>;
using Mat = vector<Vec>;

Mat Mul(const Mat& A, const Mat& B){
    Mat C(A.size(), Vec(B[0].size()));
    for(int i = 0; i < (int)A.size(); ++i){
        for(int k = 0; k < (int)B.size(); ++k){
            for(int j = 0; j < (int)B[0].size(); ++j){
                C[i][j] += A[i][k] * B[k][j];
            }
        }
    }
    return C;
}

Mat Pow(Mat A, ll n){
    Mat B(A.size(), Vec(A.size()));
    for(int i = 0; i < (int)A.size(); ++i)  B[i][i] = 1;
    while(n > 0){
        if(n & 1)   B = Mul(B, A);
        A = Mul(A, A);
        n >>= 1;
    }
    return B;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin >> N;

    Mat W(2, Vec(2));
    W[0][0] = 100; W[0][1] = 1;
    W[1][0] = 0;   W[1][1] = 1;
    W = Pow(W, N - 1);
    cout << W[0][0] + W[0][1] << endl;
    
    int M = (N * 2 - 1) % 11;
    if(M == 0){
        cout << 0 << endl;
    }
    else{
        for(int i = 0; i < M; ++i){
            cout << (i % 2 == 0 ? 1 : 0);
        }
        cout << endl;
    }

    return 0;
}
0