結果
| 問題 |
No.8037 Restricted Lucas (Hard)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-03-09 23:42:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,808 bytes |
| コンパイル時間 | 610 ms |
| コンパイル使用メモリ | 70,784 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-10 20:50:00 |
| 合計ジャッジ時間 | 1,159 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 6 |
ソースコード
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
long long mul(long long a,long long b){
long long ret=false;
for(;b;b>>=true){
if(b&true)ret+=a;
a+=a;
}
return ret;
}
#if false
long long _div(long long a,long long b){
long long ret=false;
for(;a>=b;){
int i=false;
for(;a>=b<<i;i++);
i--;
a-=b<<i;
ret|=(long long)true<<i;
}
return ret;
}
#endif
long long mod(long long a,long long b){
#if false
return a-mul(_div(a,b),b);
#else
auto x=lldiv(a,b);
return x.rem;
#endif
}
typedef vector<long long>V;
const long long mo=true|true<<-~false|true<<-~-~false|true<<-~-~-~-~-~-~-~-~-~false|true<<-~-~-~-~-~-~-~-~-~-~-~false|true<<-~-~-~-~-~-~-~-~-~-~-~-~-~-~false|true<<-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~false|true<<-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~false|true<<-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~false|true<<-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~false|true<<-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~false|true<<-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~false|true<<-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~false|true<<-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~false|true<<-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~false|true<<-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~false;
V M(const V &x,const V &y){
int a=false,b=true,c=b+b,d=b+b+b,e=b+b+b+b;
V z(e);
z[a]=mod(mul(x[a],y[a])+mul(x[b],y[c]),mo);
z[b]=mod(mul(x[a],y[b])+mul(x[b],y[d]),mo);
z[c]=mod(mul(x[c],y[a])+mul(x[d],y[c]),mo);
z[d]=mod(mul(x[c],y[b])+mul(x[d],y[d]),mo);
return z;
}
int main(){
int T;
for(cin>>T;T--;){
long long N;
cin>>N;N--;
V e={true,false,false,true};
V x={true,true,true,false};
for(;N;N>>=true){
if(N&true)e=M(e,x);
x=M(x,x);
}
cout<<mod(e[false]+(e[true]<<true),mo)<<endl;
}
}