結果

問題 No.6 使いものにならないハッシュ
ユーザー szkhtsszkhts
提出日時 2020-07-17 12:05:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,275 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 8,120 KB
最終ジャッジ日時 2023-08-18 17:47:22
合計ジャッジ時間 7,905 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
8,104 KB
testcase_01 AC 13 ms
8,120 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_prime(f, t):
    prime_list = []

    for i in range(f, t + 1):
        if i == 1:
            continue
        if i == 2:
            prime_list.append(2)
            continue
        isPrime = True
        for j in range(2, (i // 2) + 1):
            if i % j == 0:
                isPrime = False
                break
        if isPrime:
            prime_list.append(i)
        
    return prime_list;

def calc(p):
    sum = 0
    while p > 0:
        sum += p % 10
        p = p // 10
    if sum >= 10:
        sum = calc(sum)
    return sum
    
K = int(input())
N = int(input())
prime_list = make_prime(K, N)
#print(prime_list)

calc_result = []
for p in prime_list:
    calc_result.append(calc(p))
    
#print(calc_result)

hash_list = []
for i in range(len(calc_result)):
    temp = [calc_result[i]]
    length = 1
    s_idx = i
    for j in range(i + 1, len(calc_result)):
        if calc_result[j] in temp:
            break
        else:
            length += 1
            temp.append(calc_result[j])
    hash_list.append([s_idx, length])            
#print(hash_list)

max_sum = 0
max_idx = 0
for hash_item in hash_list:
    if hash_item[1] >= max_sum:
        max_sum = hash_item[1]
        max_idx = hash_item[0]
        
print(prime_list[max_idx])
0