結果

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

ソースコード

diff #

using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var t = Console.ReadLine().Trim();
        var s2 = check6(s);
        var t2 = check6(t);
        var a = (int)Pow(s2, t2) % 6;
        Console.WriteLine("428571"[a]);
    }
    public static int check6(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