結果

問題 No.746 7の倍数
ユーザー taktak
提出日時 2019-02-21 20:27:06
言語 F#
(.NET 7)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 5,564 ms
コンパイル使用メモリ 160,260 KB
実行使用メモリ 24,148 KB
最終ジャッジ日時 2023-08-13 04:01:14
合計ジャッジ時間 8,613 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
24,044 KB
testcase_01 AC 56 ms
24,060 KB
testcase_02 AC 57 ms
22,200 KB
testcase_03 AC 58 ms
21,992 KB
testcase_04 AC 57 ms
22,104 KB
testcase_05 AC 57 ms
22,244 KB
testcase_06 AC 57 ms
22,008 KB
testcase_07 AC 56 ms
22,012 KB
testcase_08 AC 57 ms
22,056 KB
testcase_09 AC 57 ms
21,996 KB
testcase_10 AC 57 ms
22,144 KB
testcase_11 AC 58 ms
20,112 KB
testcase_12 AC 58 ms
24,148 KB
testcase_13 AC 57 ms
22,256 KB
testcase_14 AC 57 ms
22,120 KB
testcase_15 AC 58 ms
24,136 KB
testcase_16 AC 58 ms
22,064 KB
testcase_17 AC 58 ms
20,024 KB
testcase_18 AC 58 ms
22,072 KB
testcase_19 AC 58 ms
22,152 KB
testcase_20 AC 58 ms
22,140 KB
testcase_21 AC 57 ms
22,164 KB
testcase_22 AC 57 ms
22,128 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

open System
open System.Text

let solve n =
  match n with
  | 0 -> "0"
  | _ -> 
    let loop = "142857"
    let loopLen = loop.Length
    let builder = StringBuilder("0.")

    let rec f (builder: StringBuilder) n =
      match n with
      | 0 -> builder
      | n -> f (builder.Append(loop)) (n-1)

    (f builder (n / loopLen)).Append(loop.Substring(0, (n % loopLen))).ToString()
  
let N = Console.ReadLine() |> int

solve N
|> Console.WriteLine
0