結果
| 問題 | 
                            No.1339 循環小数
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-11-19 21:27:14 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,486 bytes | 
| コンパイル時間 | 267 ms | 
| コンパイル使用メモリ | 82,432 KB | 
| 実行使用メモリ | 117,960 KB | 
| 最終ジャッジ日時 | 2024-09-26 06:24:45 | 
| 合計ジャッジ時間 | 4,473 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 1 | 
| other | WA * 20 RE * 16 | 
ソースコード
# d = int(input("分母 d: "))
# print("1 /", d, "を求めます。")
# # 例外処理
# if d <= 0:
#     print("条件を満たさない入力です。d>=1である必要があります。")
#     exit()
# elif d == 1:
#     print("1 / 1 = 1 です。")
#     exit()
t = int(input())
a = [int(input()) for _ in range(t)]
for d in a:
    done = False
    x = 1
    counter = 1
    isRecurringDecimal = False
    cycleLength = 0
    quotientList = []
    remainderList = [-1] * d
    remainderList[1] = 0
    while not done:
        x = x * 10
        quotientList.append(x // d)
        r = x % d
        if r == 0:
            done = True
        elif remainderList[r] != -1:
            isRecurringDecimal = True
            cycleLength = counter - remainderList[r]
            done = True
        else:
            remainderList[r] = counter
            x = r
        counter += 1
    if not isRecurringDecimal:
        print(1)
        # print("循環しません。小数点以下の商は", quotientList, "です。")
    else:
        print(cycleLength)
print()
# beforeRecurringCycle = quotientList[0:len(quotientList) - cycleLength]
# recurringCycle = quotientList[len(quotientList) - cycleLength:]
# print("循環します。")
# if beforeRecurringCycle:
#     print("循環節に含まれない部分は", beforeRecurringCycle, "です。")
# else:
#     print("循環節に含まれない部分はありません。")
# print("循環節は", recurringCycle, "です。")