結果

問題 No.186 中華風 (Easy)
ユーザー kuuso1kuuso1
提出日時 2015-04-20 00:20:31
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,674 bytes
コンパイル時間 4,602 ms
コンパイル使用メモリ 106,276 KB
実行使用メモリ 22,808 KB
最終ジャッジ日時 2023-09-17 22:06:07
合計ジャッジ時間 7,440 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
20,632 KB
testcase_01 AC 103 ms
20,756 KB
testcase_02 AC 94 ms
20,776 KB
testcase_03 AC 63 ms
18,668 KB
testcase_04 AC 111 ms
22,748 KB
testcase_05 AC 124 ms
20,656 KB
testcase_06 AC 195 ms
22,768 KB
testcase_07 AC 156 ms
20,756 KB
testcase_08 AC 198 ms
20,652 KB
testcase_09 AC 171 ms
20,752 KB
testcase_10 AC 132 ms
20,816 KB
testcase_11 AC 236 ms
20,624 KB
testcase_12 AC 108 ms
18,664 KB
testcase_13 AC 112 ms
20,808 KB
testcase_14 AC 117 ms
22,804 KB
testcase_15 AC 69 ms
20,760 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 77 ms
20,732 KB
testcase_19 AC 94 ms
20,676 KB
testcase_20 AC 88 ms
22,808 KB
testcase_21 AC 149 ms
20,632 KB
testcase_22 AC 95 ms
18,708 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;
 
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<long> L=new List<long>();
		int[] ord0=new int[6]{0,0,1,1,2,2};
		int[] ord1=new int[6]{1,2,0,2,0,1};
		int[] ord2=new int[6]{2,1,2,0,1,0};
		
		for(int t=0;t<6;t++){
			long lcm=Y[ord0[t]]*Y[ord1[t]]/gcd(Y[ord0[t]],Y[ord1[t]]);
			long tmp=-1;
			for(long x=X[ord0[t]];x<=lcm*2;x+=Y[ord0[t]]){
				if(x%Y[ord1[t]]==X[ord1[t]]){if(x!=0)tmp=x;break;}
			}
			
			if(tmp==-1){
				L.Add(-1);
				continue;;
			}
			
			long lcm2=lcm*Y[ord2[t]]/gcd(lcm,Y[ord2[t]]);
			long ans=-1;
			for(long x=tmp;x<=lcm2*2;x+=lcm){
				if(x%Y[ord2[t]]==X[ord2[t]]){if(x!=0)ans=x;break;}
			}
			L.Add(ans);
		}
		L.Sort();
		
		int ptr=0;while(ptr<6&&L[ptr]==-1)ptr++;
		Console.WriteLine(ptr==6?-1:L[ptr]);
		
		
	}
	
	
	
	long[] X,Y;
	public Sol(){
		X=new long[3];
		Y=new long[3];
		for(int i=0;i<3;i++){
			var d=rla();
			X[i]=d[0];Y[i]=d[1];
		}
	}
	long gcd(long a,long b){
		return a==0?b:gcd(b%a,a);
	}



	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
0