結果

問題 No.747 循環小数N桁目 Hard
ユーザー bluemegane
提出日時 2018-10-20 15:45:17
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,072 bytes
コンパイル時間 4,531 ms
コンパイル使用メモリ 107,004 KB
実行使用メモリ 25,992 KB
最終ジャッジ日時 2024-11-19 02:35:32
合計ジャッジ時間 6,912 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 111 WA * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

public class Hello
{
    public static void Main()
    {
        var n = Console.ReadLine().Trim();
        var k = Console.ReadLine().Trim();
        var a = getMOD6(n);
        var b = k[k.Length - 1] - '0';
        var ans = getAns(a, b);
        Console.WriteLine(ans);
    }
    public static int getAns (int a , int b )
    {
        var t = "428571";
        if (a == 2)
            if (b % 2 == 0) return 7;
            else return 8;
        else if (a == 5)
            if (b % 2 == 0) return 1;
            else return 5;
        else return t[a] - '0';
    }
    public static int getMOD6(string s)
    {
        if (s.Length == 1) return int.Parse(s) % 6;
        var sum = 0L;
        var sL = s.Length;
        for (int i = 0; i < sL - 1; i++)
            sum += s[i] - '0';
        var b = s[sL - 1] - '0';
        for (int i = 0; i <= 9; i++)
            if (((sum + i) % 3 == 0) && i % 2 == 0 )
            {
                if (b - i < 0) return b - i + 6;
                else return (b - i) % 6;
            }
        return 0;
    }
}
0