結果
| 問題 |
No.8036 Restricted Lucas (Easy)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-18 05:10:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,251 bytes |
| コンパイル時間 | 1,148 ms |
| コンパイル使用メモリ | 97,980 KB |
| 最終ジャッジ日時 | 2025-01-30 23:46:41 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 6 |
ソースコード
#include<iostream>
#include<vector>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(ll i=l;i<r;i++)
const int zero=false;
const int one=true;
const int two=one+one;
const int three=two+one;
const int four=three+one;
const int five=four+one;
const int six=five+one;
const int seven=six+one;
const int eight=seven+one;
const int nine=eight+one;
const int ten=nine+one;
const int mod=pow(ten,nine)+seven;
ll product(ll A,ll B){vector<ll>a={A},b={B};return inner_product(a.begin(),a.end(),b.begin(),0LL);}
ll remainder(ll N){
ll l=zero,r=mod;
while(r-l>one){
ll m=(l+r)>>one;
if(product(m,mod)<=N)l=m;
else r=m;
}
N-=product(l,mod);
while(N>=mod)N-=mod;
return N;
}
vector<vector<ll>>P(vector<vector<ll>>A,vector<vector<ll>>B){
vector<vector<ll>>res(two,vector<ll>(two));
FOR(i,zero,two)FOR(j,zero,two)FOR(k,zero,two)res[i][j]=remainder(res[i][j]+product(A[i][k],B[k][j]));
return res;
}
int main(){
int T;cin>>T;
while(T--){
int N;cin>>N;
vector<vector<ll>>A={{one,one},{one,zero}},E={{one,zero},{zero,one}};
while(N){
if(N&one)E=P(A,E);
A=P(A,A);
N>>=one;
}
cout<<remainder(E[one][zero]+product(two,E[one][one]))<<endl;
}
}