結果

問題 No.1339 循環小数
ユーザー tamura2004tamura2004
提出日時 2021-01-21 12:45:07
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 240 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 11,320 KB
実行使用メモリ 314,860 KB
最終ジャッジ日時 2023-08-25 23:59:28
合計ジャッジ時間 8,506 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
19,676 KB
testcase_01 AC 84 ms
15,752 KB
testcase_02 AC 84 ms
15,384 KB
testcase_03 AC 83 ms
15,496 KB
testcase_04 AC 83 ms
15,464 KB
testcase_05 AC 83 ms
15,632 KB
testcase_06 AC 83 ms
15,680 KB
testcase_07 AC 82 ms
15,464 KB
testcase_08 AC 83 ms
15,700 KB
testcase_09 AC 84 ms
15,596 KB
testcase_10 AC 83 ms
15,604 KB
testcase_11 AC 247 ms
42,364 KB
testcase_12 AC 266 ms
46,436 KB
testcase_13 AC 211 ms
35,592 KB
testcase_14 AC 235 ms
40,156 KB
testcase_15 AC 236 ms
41,772 KB
testcase_16 AC 215 ms
38,236 KB
testcase_17 AC 278 ms
46,288 KB
testcase_18 AC 198 ms
34,012 KB
testcase_19 AC 198 ms
34,488 KB
testcase_20 AC 187 ms
32,344 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def solve
  n = gets.to_s.to_i
  x = 1
  i = 0
  cnt = {}
  while cnt[x].nil?
    cnt[x] = i
    x = (x * 10) % n
    if x.zero?
      return 1
    end
    i += 1
  end
  return i - cnt[x]
end

t = gets.to_s.to_i
t.times do
  puts solve
end
0