結果

問題 No.639 An Ordinary Sequence
ユーザー mencottonmencotton
提出日時 2018-01-26 22:55:09
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 300 ms / 1,000 ms
コード長 674 bytes
コンパイル時間 2,226 ms
コンパイル使用メモリ 99,772 KB
実行使用メモリ 23,700 KB
最終ジャッジ日時 2023-08-30 12:49:03
合計ジャッジ時間 5,850 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 276 ms
23,700 KB
testcase_01 AC 300 ms
19,504 KB
testcase_02 AC 58 ms
21,472 KB
testcase_03 AC 58 ms
21,576 KB
testcase_04 AC 59 ms
21,656 KB
testcase_05 AC 60 ms
21,496 KB
testcase_06 AC 59 ms
21,524 KB
testcase_07 AC 59 ms
21,608 KB
testcase_08 AC 59 ms
23,608 KB
testcase_09 AC 59 ms
21,540 KB
testcase_10 AC 59 ms
21,604 KB
testcase_11 AC 59 ms
21,648 KB
testcase_12 AC 62 ms
23,556 KB
testcase_13 AC 66 ms
21,600 KB
testcase_14 AC 79 ms
21,536 KB
testcase_15 AC 126 ms
21,556 KB
testcase_16 AC 299 ms
21,420 KB
testcase_17 AC 59 ms
21,480 KB
testcase_18 AC 299 ms
23,576 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace _639
{
    class Program
    {
        public static long[] a = new long[100000];
        static void makesmallanswer()
        {
            a[0] = 1;
            for (long i = 1; i < 100000; i++)
            {
                a[i] = a[i / 3] + a[i / 5];
            }
        }
        static long solve(long n)
        {
            if (n == 0) return 1;
            if (n < 100000) return a[n];
            return solve(n / 3) + solve(n / 5);
        }
        static void Main(string[] args)
        {
            makesmallanswer();
            long x = long.Parse(Console.ReadLine());
            Console.WriteLine(solve(x));
        }
    }
}
0