結果
| 問題 |
No.653 E869120 and Lucky Numbers
|
| コンテスト | |
| ユーザー |
AreTrash
|
| 提出日時 | 2018-03-02 17:37:25 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 35 ms / 2,000 ms |
| コード長 | 797 bytes |
| コンパイル時間 | 976 ms |
| コンパイル使用メモリ | 114,700 KB |
| 実行使用メモリ | 27,412 KB |
| 最終ジャッジ日時 | 2024-09-13 18:18:45 |
| 合計ジャッジ時間 | 2,954 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Linq;
namespace No653
{
class Program
{
static void Main(string[] args)
{
var P = Console.ReadLine().Reverse().Select(c => c - '0').ToArray();
Func<int, bool> dfs = null;
dfs = digit =>
{
if (digit >= P.Length) return false;
if (P[digit] == 1 && digit + 1 == P.Length) return true;
if (P[digit] == 7 || P[digit] == 8) return P.Skip(digit + 1).All(x => x == 6 || x == 7);
if (new[] { 3, 4, 5 }.Contains(P[digit])) return dfs(digit + 1);
return false;
};
var res = new[] {2, 3, 4}.Contains(P[0]) && P.Length >= 2 && dfs(1);
Console.WriteLine(res ? "Yes" : "No");
}
}
}
AreTrash