結果

問題 No.492 IOI数列
ユーザー mbanmban
提出日時 2017-04-13 21:01:58
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 57 ms / 1,000 ms
コード長 1,483 bytes
コンパイル時間 5,722 ms
コンパイル使用メモリ 106,096 KB
実行使用メモリ 24,768 KB
最終ジャッジ日時 2023-09-25 16:30:06
合計ジャッジ時間 8,018 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
20,704 KB
testcase_01 AC 57 ms
22,840 KB
testcase_02 AC 54 ms
20,788 KB
testcase_03 AC 54 ms
20,732 KB
testcase_04 AC 55 ms
20,828 KB
testcase_05 AC 55 ms
22,708 KB
testcase_06 AC 54 ms
22,712 KB
testcase_07 AC 54 ms
20,748 KB
testcase_08 AC 56 ms
22,688 KB
testcase_09 AC 55 ms
20,800 KB
testcase_10 AC 55 ms
22,756 KB
testcase_11 AC 54 ms
20,636 KB
testcase_12 AC 55 ms
20,680 KB
testcase_13 AC 54 ms
22,752 KB
testcase_14 AC 55 ms
24,768 KB
testcase_15 AC 55 ms
20,584 KB
testcase_16 AC 56 ms
20,624 KB
testcase_17 AC 54 ms
20,768 KB
testcase_18 AC 55 ms
20,856 KB
testcase_19 AC 55 ms
20,832 KB
testcase_20 AC 57 ms
20,644 KB
testcase_21 AC 57 ms
20,788 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

public class Magatro 
{
    private long N;
    private int Mod = (int)1e9 + 7;
    private long[] Anser = new long[] { 0l, 1l, 101l, 10101l, 1010101l, 101010101l, 10101010101l, 1010101010101l,
            101010101010101l, 10101010101010101l, 1010101010101010101l };

    private void Scan()
    {
        N = long.Parse(Console.ReadLine());
    }

    private long Pow(long a, long b, long mod)
    {
        long result = 1;
        while (b > 0)
        {
            if (b % 2 == 1)
            {
                result *= a;
                result %= mod;
            }
            a *= a;
            a %= mod;
            b /= 2;
        }
        return result;
    }

    private long Function(long i, long mod)
    {
        if (i == 0)
        {
            return 0;
        }
        if (i == 1)
        {
            return 1;
        }
        if (i % 2 == 1)
        {
            long res = Function(i - 1, mod) * 100 + 1;
            res %= mod;
            return res;
        }
        else
        {
            long res = Function(i / 2, mod);
            res *= Pow(100, i / 2, mod) + 1;
            res %= mod;
            return res;
        }
    }

    public void Solve()
    {
        Scan();
        Console.WriteLine(Function(N, Mod));
        Console.WriteLine(Anser[N % 11]);
    }
}
0