結果

問題 No.766 金魚すくい
ユーザー lam6er
提出日時 2025-04-09 20:57:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,185 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 82,608 KB
実行使用メモリ 85,120 KB
最終ジャッジ日時 2025-04-09 20:58:47
合計ジャッジ時間 5,714 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10**9 + 7

def main():
    import sys
    input = sys.stdin.read().split()
    ptr = 0
    N = int(input[ptr])
    ptr +=1
    M = int(input[ptr])
    ptr +=1
    P = int(input[ptr])
    ptr +=1
    V = list(map(int, input[ptr:ptr+N]))
    ptr += N
    
    V.sort(reverse=True)
    
    # Calculate S = (100-P)/100 mod MOD
    inv100 = pow(100, MOD-2, MOD)
    S = ( (100 - P) * inv100 ) % MOD
    
    s_power = 1  # S^0
    ans = 0
    
    for i in range(N):
        # For the i-th goldfish (0-based in V)
        # S_power starts as S^0, then after multiply, becomes S^(i+1)
        # Wait, the first goldfish is i=1 in the problem's terms, but the code uses 0-based
        # So for the code, i runs from 0 to N-1, and each iteration represents i+1 in the problem.
        s_power = (s_power * S) % MOD
        
        # t_i = (1 - s_power) mod MOD
        t_i = (1 - s_power) % MOD
        
        # u_i = (t_i)^M mod MOD
        u_i = pow(t_i, M, MOD)
        
        # p_i = (1 - u_i) mod MOD
        p_i = (1 - u_i) % MOD
        
        # ans += V[i] * p_i
        ans = (ans + V[i] * p_i) % MOD
    
    print(ans % MOD)
    
if __name__ == '__main__':
    main()
0