結果

問題 No.639 An Ordinary Sequence
ユーザー mencotton
提出日時 2018-01-26 22:55:09
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 272 ms / 1,000 ms
コード長 674 bytes
コンパイル時間 2,721 ms
コンパイル使用メモリ 113,832 KB
実行使用メモリ 27,252 KB
最終ジャッジ日時 2025-01-02 02:07:01
合計ジャッジ時間 3,771 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
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