結果
問題 | No.293 4>7の世界 |
ユーザー |
![]() |
提出日時 | 2016-09-22 15:41:07 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 1,220 bytes |
コンパイル時間 | 6,147 ms |
コンパイル使用メモリ | 106,496 KB |
実行使用メモリ | 18,688 KB |
最終ジャッジ日時 | 2024-12-30 12:14:04 |
合計ジャッジ時間 | 7,400 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
コンパイルメッセージ
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; class Program { static int ReadInt() { return int.Parse(Console.ReadLine()); } static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); } static string[] ReadStrings() { return Console.ReadLine().Split(); } static void Calc(string a, string b) { if (a.Length == b.Length) { for (int i = 0; i < a.Length; i++) { int x = a[i] - '0'; int y = b[i] - '0'; if (x == 4 && y == 7) { Console.WriteLine(a); return; } else if (x == 7 && y == 4) { Console.WriteLine(b); return; } else if (x != y) { Console.WriteLine(x < y ? b : a); return; } } // a == b Console.WriteLine(a); } else { var x = new[] { a, b }.OrderBy(e => e.Length).Last(); Console.WriteLine(x); } } static void Main() { var ab = ReadStrings(); Calc(ab[0], ab[1]); } }