結果

問題 No.435 占い(Extra)
ユーザー ytftytft
提出日時 2021-03-24 09:05:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,282 bytes
コンパイル時間 1,735 ms
コンパイル使用メモリ 170,872 KB
実行使用メモリ 159,304 KB
最終ジャッジ日時 2023-08-17 19:06:52
合計ジャッジ時間 10,629 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main(){
    long long M=10000000;
    vector<long long> 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;
    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]=table[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+table[n-j]/6-table[j]/6)*6;
            C[j]+=(C[j-1]%6+table[n-j]%6-table[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;
    }
}
0