結果
| 問題 |
No.435 占い(Extra)
|
| コンテスト | |
| ユーザー |
🐬hec
|
| 提出日時 | 2016-05-04 00:02:37 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 946 ms / 2,000 ms |
| コード長 | 2,254 bytes |
| コンパイル時間 | 2,499 ms |
| コンパイル使用メモリ | 114,816 KB |
| 実行使用メモリ | 30,380 KB |
| 最終ジャッジ日時 | 2024-10-08 11:30:13 |
| 合計ジャッジ時間 | 11,170 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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());
}
}
🐬hec