結果

問題 No.435 占い(Extra)
ユーザー 🐬hec🐬hec
提出日時 2016-05-04 00:02:37
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 954 ms / 2,000 ms
コード長 2,254 bytes
コンパイル時間 4,467 ms
コンパイル使用メモリ 106,368 KB
実行使用メモリ 21,888 KB
最終ジャッジ日時 2024-04-17 02:20:14
合計ジャッジ時間 13,078 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
17,792 KB
testcase_01 AC 25 ms
17,664 KB
testcase_02 AC 26 ms
17,408 KB
testcase_03 AC 26 ms
17,664 KB
testcase_04 AC 27 ms
17,792 KB
testcase_05 AC 25 ms
17,664 KB
testcase_06 AC 32 ms
18,048 KB
testcase_07 AC 26 ms
17,792 KB
testcase_08 AC 26 ms
17,664 KB
testcase_09 AC 25 ms
18,048 KB
testcase_10 AC 30 ms
17,664 KB
testcase_11 AC 29 ms
17,664 KB
testcase_12 AC 53 ms
17,792 KB
testcase_13 AC 55 ms
17,792 KB
testcase_14 AC 57 ms
17,792 KB
testcase_15 AC 62 ms
18,048 KB
testcase_16 AC 121 ms
21,632 KB
testcase_17 AC 683 ms
21,888 KB
testcase_18 AC 56 ms
17,664 KB
testcase_19 AC 56 ms
17,792 KB
testcase_20 AC 317 ms
17,536 KB
testcase_21 AC 320 ms
17,664 KB
testcase_22 AC 330 ms
17,664 KB
testcase_23 AC 331 ms
18,176 KB
testcase_24 AC 391 ms
21,888 KB
testcase_25 AC 954 ms
21,760 KB
testcase_26 AC 354 ms
17,664 KB
testcase_27 AC 327 ms
17,792 KB
testcase_28 AC 26 ms
17,664 KB
testcase_29 AC 316 ms
17,536 KB
testcase_30 AC 281 ms
17,664 KB
testcase_31 AC 261 ms
17,536 KB
testcase_32 AC 279 ms
17,664 KB
testcase_33 AC 361 ms
19,456 KB
testcase_34 AC 604 ms
21,760 KB
testcase_35 AC 328 ms
18,304 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
 
class Yukicoder0466
{
 
    public Yukicoder0466() { }
    public static int Main()
    {
        new Yukicoder0466().calc();
        return 0;
    }
 
    Scanner cin;
 
    void calc()
    {
        cin = new Scanner();
		
		int[] num_idx = new int[] {0,0,1,0,2,5,0,4,3,0};
        int[] two_idx = new int[] {1,2,4,8,7,5};

        int t = cin.nextInt();
        
        for(;t>0;--t){
            int n=cin.nextInt(),x=cin.nextInt(),a=cin.nextInt(),b=cin.nextInt(),m=cin.nextInt();         
            bool allzero=true;
           

            int ans=0,num=n-1,den=1,two=0,three=0,tmp;

            for(int i=0;i<n;++i){
                int s=x%10;
                x=((x^a)+b)%m;
            
                if(s!=0) allzero=false;

                if(three<=1){
                    int cur=s;
                    cur=cur*two_idx[two%6]*(three==1?3:1);
                    ans+=cur;
                }
                
                if(i==n-1) break;

                tmp=num;
                while(tmp%3==0){
                    tmp/=3;three++;
                }
                two+=(num_idx[tmp%9]);
                
                tmp=den;
                while(tmp%3==0){
                    tmp/=3;three--;
                }
                two+=(6-num_idx[tmp%9]);
                
                num--;den++;
            }

            ans%=9;
            if(allzero==false && ans==0) ans=9;
            Console.WriteLine(ans);
        }

    }
}
 
 
 
 
 
class Scanner
{
    string[] s;
    int i;
 
    char[] cs = new char[] { ' ' };
 
    public Scanner()
    {
        s = new string[0];
        i = 0;
    }
 
    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }
 
    public int nextInt()
    {
        return int.Parse(next());
    }
 
    public long nextLong()
    {
        return long.Parse(next());
    }
 
    public double nextDouble()
    {
        return double.Parse(next());
    }
 
}
0