結果

問題 No.435 占い(Extra)
ユーザー ytftytft
提出日時 2021-03-24 08:45:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,254 bytes
コンパイル時間 1,612 ms
コンパイル使用メモリ 170,420 KB
実行使用メモリ 120,212 KB
最終ジャッジ日時 2023-08-17 18:22:39
合計ジャッジ時間 9,504 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
42,152 KB
testcase_01 AC 31 ms
42,116 KB
testcase_02 AC 32 ms
42,176 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 35 ms
42,200 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 34 ms
42,996 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 MLE -
testcase_21 MLE -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 MLE -
testcase_27 WA -
testcase_28 WA -
testcase_29 MLE -
testcase_30 MLE -
testcase_31 MLE -
testcase_32 MLE -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int M=10000000;
    vector<int> table(M);
    vector<int> l2={0,0,1,0,2,5,0,4,3};
    table[0]=-1;
    for(int i=1;i<M;i++){
        if(i%3==0){
            table[i]=table[i/3]+6;
        }else{
            table[i]=l2[i%9];
        }
    }
    int T;
    cin>>T;
    int n,a,b,x,m;
    vector<int> S,C;
    int cur;
    bool flg;
    int temp;
    int 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]=table[x%10];
            x=((x^a)+b)%m;
        }
        cur=0;
        for(int j=0;j<n;j++){
            C[j]=cur;
            cur+=(table[n-j-1]/6-table[j+1]/6)*6;
            cur+=(table[n-j-1]%6-table[j+1]%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;
    }
}
0