結果

問題 No.6 使いものにならないハッシュ
ユーザー konchanksu
提出日時 2020-04-28 22:30:44
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 545 ms / 5,000 ms
コード長 930 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-09-16 16:56:14
合計ジャッジ時間 9,081 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

def Hash(start, end):
    best = (start, 0)
    lists = []
    Prlist = []
    for i in range(start, end + 1):
        tmp = Prime_num(i)
        if tmp != -1:
            Prlist.append(i)
            for j in range(len(lists)):
                if lists[j] == tmp:
                    lists = lists[j + 1:]
                    break
            lists.append(tmp)
            if len(lists) == best[1]:
                best = (Prlist[-len(lists)], best[1])
            elif len(lists) > best[1]:
                best = (best[0], best[1] + 1)
    
    print(best[0])

def Prime_num(num):
    if num == 1:
        return -1
    for i in range(2, int(num ** 0.5) + 1):
        if num % i == 0:
            return -1 
    return Get_hash(num)
    
def Get_hash(num):   
    ans = 0
    for i in str(num):
        ans += int(i)
    if ans >= 10:
        return Get_hash(ans)
    return ans

K, N = int(input()), int(input())
Hash(K, N)

0