結果
| 問題 |
No.435 占い(Extra)
|
| コンテスト | |
| ユーザー |
ytft
|
| 提出日時 | 2021-03-24 09:11:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,205 bytes |
| コンパイル時間 | 1,449 ms |
| コンパイル使用メモリ | 171,320 KB |
| 実行使用メモリ | 81,664 KB |
| 最終ジャッジ日時 | 2024-11-26 18:37:30 |
| 合計ジャッジ時間 | 25,429 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 MLE * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int t(int a){
vector<int> l2={0,0,1,0,2,5,0,4,3};
if(a==0){
return -1;
}
int ans=0;
while(a%3==0){
a/=3;
ans+=6;
}
ans+=l2[a%9];
return ans;
}
int main(){
int T;
cin>>T;
long long n,a,b,x,m;
vector<int> S,C;
bool flg;
long long temp;
long long ans;
for(int i=0;i<T;i++){
cin>>n>>x>>a>>b>>m;
S.resize(n);
C.resize(n);
for(int j=0;j<n;j++){
S[j]=t(x%10);
x=((x^a)+b)%m;
}
C[0]=0;
for(int j=1;j<n;j++){
C[j]=0;
C[j]+=(C[j-1]/6+t(n-j)/6-t(j)/6)*6;
C[j]+=(C[j-1]%6+t(n-j)%6-t(j)%6+6)%6;
}
flg=true;
ans=0;
for(int j=0;j<n;j++){
if(S[j]==-1){
continue;
}
flg=false;
temp=0;
temp+=(S[j]/6+C[j]/6)*6;
temp+=(S[j]%6+C[j]%6)%6;
if(temp<6){
ans=(ans+(1<<(temp%6)))%9;
}else if(temp<12){
ans=(ans+(1<<(temp%6))*3)%9;
}
}
cout<<(flg?0:(ans+8)%9+1)<<endl;
}
}
ytft