結果

問題 No.435 占い(Extra)
ユーザー ytftytft
提出日時 2021-03-24 09:16:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 969 bytes
コンパイル時間 1,567 ms
コンパイル使用メモリ 167,360 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-17 19:17:04
合計ジャッジ時間 9,787 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
    int S,C;
    bool flg;
    long long temp;
    long long ans;
    for(int i=0;i<T;i++){
        cin>>n>>x>>a>>b>>m;
        flg=true;
        ans=0;
        C=0;
        for(int j=0;j<n;j++){
            S=t(x%10);
            if(S==-1){
                continue;
            }
            flg=false;
            temp=(S/6+C/6)*6+(S%6+C%6)%6;
            if(temp<6){
                ans=(ans+(1<<(temp%6)))%9;
            }else if(temp<12){
                ans=(ans+(1<<(temp%6))*3)%9;
            }
            x=((x^a)+b)%m;
            C=(C/6+t(n-j-1)/6-t(j+1)/6)*6+(C%6+t(n-j-1)%6-t(j+1)%6+6)%6;
        }
        cout<<(flg?0:(ans+8)%9+1)<<endl;
    }
}
0