結果

問題 No.492 IOI数列
ユーザー platypus999
提出日時 2017-03-10 23:28:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,273 bytes
コンパイル時間 1,147 ms
コンパイル使用メモリ 101,740 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-24 08:51:11
合計ジャッジ時間 1,861 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
struct four
{
ll p, q, r, s;
four(ll p_, ll q_, ll r_, ll s_)
:p(p_), q(q_), r(r_), s(s_)
{}
four operator* (const four& o)
{
four ret(p * o.p + r * o.q, q * o.p + s * o.q, p * o.r + r * o.s, q * o.r + s * o.s);
ret.p %= MOD;
ret.q %= MOD;
ret.r %= MOD;
ret.s %= MOD;
return ret;
}
};
four one(100, 1, 0, 1);
four matpow(ll x)
{
if (x == 0)return four(1, 0, 0, 1);
four half = matpow(x / 2);
half = half * half;
if (x % 2)half = half * one;
return half;
}
ll luzhiled[11] = {
0,
1,
101,
10101,
1010101,
101010101,
10101010101,
1010101010101,
101010101010101,
10101010101010101,
1010101010101010101, };
int main(void)
{
ll n;
cin >> n;
four ret = matpow(n - 1);
ll izryt = (ret.p + ret.q) % MOD;
cout << izryt << endl;
cout << luzhiled[n % 11] << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0