結果
| 問題 | No.186 中華風 (Easy) |
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2015-04-20 00:20:31 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,674 bytes |
| 記録 | |
| コンパイル時間 | 2,411 ms |
| コンパイル使用メモリ | 107,776 KB |
| 実行使用メモリ | 18,048 KB |
| 最終ジャッジ日時 | 2024-07-04 15:52:36 |
| 合計ジャッジ時間 | 5,222 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 2 |
コンパイルメッセージ
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;
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));}
}
kuuso1