結果

問題 No.435 占い(Extra)
ユーザー ytftytft
提出日時 2021-03-24 09:11:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,205 bytes
コンパイル時間 1,626 ms
コンパイル使用メモリ 169,304 KB
実行使用メモリ 81,360 KB
最終ジャッジ日時 2023-08-17 19:12:06
合計ジャッジ時間 28,031 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 5 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 18 ms
4,380 KB
testcase_11 AC 17 ms
4,376 KB
testcase_12 AC 158 ms
11,052 KB
testcase_13 AC 155 ms
4,380 KB
testcase_14 AC 155 ms
4,384 KB
testcase_15 AC 157 ms
4,376 KB
testcase_16 AC 189 ms
4,380 KB
testcase_17 AC 449 ms
4,376 KB
testcase_18 AC 164 ms
10,936 KB
testcase_19 AC 162 ms
4,376 KB
testcase_20 MLE -
testcase_21 AC 1,525 ms
10,880 KB
testcase_22 AC 1,533 ms
4,380 KB
testcase_23 AC 1,536 ms
4,380 KB
testcase_24 AC 1,559 ms
4,376 KB
testcase_25 AC 1,854 ms
4,380 KB
testcase_26 MLE -
testcase_27 AC 1,583 ms
10,880 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1,492 ms
11,080 KB
testcase_30 MLE -
testcase_31 AC 1,249 ms
40,332 KB
testcase_32 AC 1,392 ms
15,736 KB
testcase_33 AC 1,579 ms
4,380 KB
testcase_34 AC 1,728 ms
4,380 KB
testcase_35 AC 1,568 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    }
}
0