結果

問題 No.186 中華風 (Easy)
ユーザー kuuso1kuuso1
提出日時 2015-04-20 00:16:54
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,651 bytes
コンパイル時間 2,810 ms
コンパイル使用メモリ 108,412 KB
実行使用メモリ 22,780 KB
最終ジャッジ日時 2023-09-18 02:14:56
合計ジャッジ時間 6,451 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
22,700 KB
testcase_01 AC 102 ms
20,792 KB
testcase_02 AC 96 ms
20,648 KB
testcase_03 AC 65 ms
20,884 KB
testcase_04 AC 110 ms
22,688 KB
testcase_05 AC 123 ms
18,748 KB
testcase_06 AC 192 ms
20,644 KB
testcase_07 AC 155 ms
22,728 KB
testcase_08 AC 195 ms
20,784 KB
testcase_09 AC 171 ms
22,756 KB
testcase_10 AC 113 ms
22,780 KB
testcase_11 AC 235 ms
20,692 KB
testcase_12 AC 108 ms
20,648 KB
testcase_13 AC 111 ms
20,808 KB
testcase_14 AC 118 ms
20,708 KB
testcase_15 AC 69 ms
20,700 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 78 ms
20,728 KB
testcase_19 AC 92 ms
20,760 KB
testcase_20 AC 78 ms
22,756 KB
testcase_21 AC 109 ms
20,724 KB
testcase_22 AC 83 ms
20,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;x+=Y[ord0[t]]){
				if(x%Y[ord1[t]]==X[ord1[t]]){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;x+=lcm){
				if(x%Y[ord2[t]]==X[ord2[t]]){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