結果
| 問題 |
No.639 An Ordinary Sequence
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2018-09-09 13:53:59 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 1,000 ms |
| コード長 | 636 bytes |
| コンパイル時間 | 941 ms |
| コンパイル使用メモリ | 110,748 KB |
| 実行使用メモリ | 26,608 KB |
| 最終ジャッジ日時 | 2025-01-02 02:33:13 |
| 合計ジャッジ時間 | 2,258 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / 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.
ソースコード
using System.Collections.Generic;
using System;
public class Hello
{
public static void Main()
{
var d = new Dictionary<long, long>();
d[0] = 1; d[1] = 2; d[2] = 2;
var n = long.Parse(Console.ReadLine().Trim());
var res = func( d, n);
Console.WriteLine(res);
}
public static long func (Dictionary<long,long> d, long n)
{
if (n == 0) return 1;
if (n == 1 | n == 2) return 2;
var a = n / 3;
var b = n / 5;
if (!d.ContainsKey(a)) d[a] = func(d, a);
if (!d.ContainsKey(b)) d[b] = func(d, b);
return d[a] + d[b];
}
}
bluemegane