結果
問題 | No.186 中華風 (Easy) |
ユーザー | mban |
提出日時 | 2017-04-16 17:03:22 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,222 bytes |
コンパイル時間 | 4,429 ms |
コンパイル使用メモリ | 115,480 KB |
実行使用メモリ | 25,952 KB |
最終ジャッジ日時 | 2024-07-19 04:04:09 |
合計ジャッジ時間 | 6,004 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
23,984 KB |
testcase_01 | AC | 25 ms
23,652 KB |
testcase_02 | AC | 26 ms
21,816 KB |
testcase_03 | AC | 22 ms
25,884 KB |
testcase_04 | AC | 34 ms
25,952 KB |
testcase_05 | AC | 30 ms
23,728 KB |
testcase_06 | AC | 35 ms
21,808 KB |
testcase_07 | AC | 32 ms
23,912 KB |
testcase_08 | AC | 41 ms
23,832 KB |
testcase_09 | AC | 41 ms
23,940 KB |
testcase_10 | AC | 38 ms
25,820 KB |
testcase_11 | AC | 46 ms
23,784 KB |
testcase_12 | AC | 30 ms
23,532 KB |
testcase_13 | AC | 29 ms
23,704 KB |
testcase_14 | AC | 30 ms
23,788 KB |
testcase_15 | AC | 23 ms
23,832 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 25 ms
23,912 KB |
testcase_19 | AC | 33 ms
23,528 KB |
testcase_20 | AC | 25 ms
23,776 KB |
testcase_21 | AC | 33 ms
21,796 KB |
testcase_22 | AC | 35 ms
23,596 KB |
コンパイルメッセージ
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.Generic; using System.Linq; using System.Collections; using System.IO; class Program { static void Main(string[] args) { new Magatro().Solve(); } } public class Scanner { private StreamReader Sr; private string[] S; private int Index; private const char Separator = ' '; public Scanner(Stream stream) { Index = 0; S = new string[0]; Sr = new StreamReader(stream); } private string[] Line() { return Sr.ReadLine().Split(Separator); } public string Next() { string result; if (Index >= S.Length) { S = Line(); Index = 0; } result = S[Index]; Index++; return result; } public int NextInt() { return int.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } public decimal NextDecimal() { return decimal.Parse(Next()); } public string[] StringArray(int index = 0) { Next(); Index = S.Length; return S.Skip(index).ToArray(); } public int[] IntArray(int index = 0) { return StringArray(index).Select(int.Parse).ToArray(); } public long[] LongArray(int index = 0) { return StringArray(index).Select(long.Parse).ToArray(); } public bool EndOfStream { get { return Sr.EndOfStream; } } } public class Magatro { private int X1, X2, X3, Y1, Y2, Y3; long ans; private void Scan() { Scanner scanner = new Scanner(Console.OpenStandardInput()); X1 = scanner.NextInt(); Y1 = scanner.NextInt(); X2 = scanner.NextInt(); Y2 = scanner.NextInt(); X3 = scanner.NextInt(); Y3 = scanner.NextInt(); } public void Solve() { Scan(); ans = X1; bool flag = false; for (long i = 0; i <= Y2; i++) { long j = ans + Y1 * i; if (j % Y2 == X2) { flag = true; ans = j; break; } } if (!flag) { Console.WriteLine(-1); return; } long lcm = LCM(Y1, Y2); flag = false; for (long i = 0; i <= Y3; i++) { long j = ans + lcm * i; if (j % Y3 == X3) { flag = true; ans = j; break; } } if (!flag) { Console.WriteLine(-1); return; } Console.WriteLine(ans); } private long LCM(long a, long b) { return (a * b) / GCD(a, b); } private long GCD(long a, long b) { if (a < b) { Swap(ref a, ref b); } long r = a % b; while (r > 0) { a = b; b = r; r = a % b; } return b; } private void Swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; } }