結果

問題 No.492 IOI数列
ユーザー はまやんはまやん
提出日時 2017-03-11 01:13:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,849 bytes
コンパイル時間 1,613 ms
コンパイル使用メモリ 171,972 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-24 09:26:54
合計ジャッジ時間 2,427 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
#define mod1 1000000007LL
struct Mat1 { // by MrDindows
using T = ll;
T a[2][2];
Mat1() {
memset(a, 0, sizeof(a));
}
static Mat1 One() {
Mat1 r;
r[0][0] = r[1][1] = 1;
return r;
}
T* operator[](int idx) {
return a[idx];
}
const T* operator[](int idx) const {
return a[idx];
}
Mat1 operator+(const Mat1& b) {
Mat1 r;
rep(i, 0, 2) rep(j, 0, 2) {
r[i][j] = a[i][j] + b[i][j];
if (r[i][j] >= mod1) {
r[i][j] -= mod1;
}
}
return r;
}
Mat1& operator*=(const Mat1& b) {
return *this = *this * b;
}
Mat1 operator*(const Mat1& b) {
Mat1 r;
rep(i, 0, 2) rep(j, 0, 2) {
rep(k, 0, 2) {
r[i][j] += a[i][k] * b[k][j];
}
r[i][j] %= mod1;
}
return r;
}
Mat1 power(ll n) {
if (n == 0) return Mat1::One();
if (n == 1) return *this;
Mat1 t = power(n / 2);
t = t * t;
if (n % 2) {
t = t * *this;
}
return t;
}
void print() {
rep(i, 0, 2) {
cout << "[" << a[i][0] << ", " << a[i][1] << "]" << endl;
}
cout << endl;
}
bool empty() {
return a[0][0] == 1 && a[0][1] == 0 && a[1][0] == 0 && a[1][1] == 1;
}
void clear() {
*this = Mat1::One();
}
};
//-----------------------------------------------------------------
ll solA(ll N) {
Mat1 m;
m.a[0][0] = 100;
m.a[0][1] = 1;
m.a[1][0] = 0;
m.a[1][1] = 1;
m = m.power(N - 1);
return (m.a[0][0] + m.a[0][1]) % mod1;
}
//-----------------------------------------------------------------
string solB(ll N) {
N %= 11;
ll n = 1 + (N - 1) * 2;
string sa = "";
rep(i, 0, n) {
if (i % 2 == 0) sa = sa + "1";
else sa = sa + "0";
}
return sa;
}
//-----------------------------------------------------------------
int main() {
ll N;
cin >> N;
cout << solA(N) << endl;
cout << solB(N) << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0