結果
問題 | No.8036 Restricted Lucas (Easy) |
ユーザー |
![]() |
提出日時 | 2018-04-01 23:26:08 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,006 bytes |
コンパイル時間 | 808 ms |
コンパイル使用メモリ | 81,100 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 06:07:51 |
合計ジャッジ時間 | 1,451 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 6 |
ソースコード
#include <iostream>#include <vector>#include <string>#include <cmath>#include <algorithm>#include <utility>#include <queue>#include <set>#include <map>#include <cstdlib>using namespace std;typedef long long ll;typedef pair<int,int> PII;typedef vector<int> VI;typedef vector<VI> VVI;#define MP make_pair#define PB push_backll mod;ll one(){ll a = (ll)true;return a;}ll two(){ll a = (ll)true;a++;return a;}ll three(){ll a = (ll)true;a++;a++;return a;}ll seven(){ll a = three();a++;a++;a++;a++;return a;}ll nine(){return two()+seven();}ll ten(){ll a = nine();a++;return a;}ll zero(){ll a = one();a--;return a;}void mod_calc(){mod = one();for(int i=zero();i<nine();i++){mod *= ten();}mod += seven();return;}ll divide(ll a,ll b){lldiv_t c = div(a,b);return c.quot;}ll modulo(ll a,ll b){lldiv_t c = div(a,b);return c.rem;}ll mul(ll a,ll b){if(b==zero())return zero();if(b==one())return a;if(modulo(b,two())==zero()){ll c = mul(a,divide(b,two()));return modulo(c+c,mod);}else{ll c = mul(a,divide(b,two()));return modulo(c+c+a,mod);}}vector<vector<ll> > mat_mul(vector<vector<ll> > &v,vector<vector<ll> > &w){vector<vector<ll> > z(two(),vector<ll>(two()));z[zero()][zero()] = modulo(mul(v[zero()][zero()],w[zero()][zero()])+mul(v[zero()][one()],w[one()][zero()]),mod);z[zero()][one()] = modulo(mul(v[zero()][zero()],w[zero()][one()])+mul(v[zero()][one()],w[one()][one()]),mod);z[one()][zero()] = modulo(mul(v[one()][zero()],w[zero()][zero()])+mul(v[one()][one()],w[one()][zero()]),mod);z[one()][one()] = modulo(mul(v[one()][zero()],w[zero()][one()])+mul(v[one()][one()],w[one()][one()]),mod);return z;}vector<vector<ll> > mat_calc(vector<vector<ll> > &v,ll n){if(n==zero()){vector<vector<ll> > z(two(),vector<ll>(two()));z[zero()][zero()]=one();z[one()][one()]=one();return z;}if(n==one())return v;if(modulo(n,two())==zero()){vector<vector<ll> > z(two(),vector<ll>(two()));z = mat_calc(v,divide(n,two()));return mat_mul(z,z);}else{vector<vector<ll> > z(two(),vector<ll>(two()));z = mat_calc(v,divide(n,two()));z = mat_mul(z,z);return mat_mul(z,v);}}ll calc(ll n){vector<vector<ll> > v(two(),vector<ll>(two()));v[zero()][zero()] = zero();v[zero()][one()] = one();v[one()][zero()] = one();v[one()][one()] = one();vector<vector<ll> > z(two(),vector<ll>(two()));z = mat_calc(v,n);return modulo(mul(z[zero()][zero()],two())+mul(z[zero()][one()],one()),mod);}int main(){mod_calc();int t;cin >> t;for(int i=zero();i<t;i++){ll n;cin >> n;cout << calc(n) << endl;}return zero();}