結果

問題 No.1259 スイッチ
ユーザー buey_tbuey_t
提出日時 2023-04-04 12:21:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,041 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 256,556 KB
最終ジャッジ日時 2024-04-08 11:42:40
合計ジャッジ時間 31,291 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 434 ms
256,552 KB
testcase_01 AC 428 ms
256,552 KB
testcase_02 AC 434 ms
256,552 KB
testcase_03 AC 445 ms
256,552 KB
testcase_04 AC 435 ms
256,552 KB
testcase_05 AC 437 ms
256,552 KB
testcase_06 AC 442 ms
256,552 KB
testcase_07 AC 415 ms
256,552 KB
testcase_08 AC 424 ms
256,552 KB
testcase_09 AC 433 ms
256,552 KB
testcase_10 AC 446 ms
256,552 KB
testcase_11 AC 450 ms
256,552 KB
testcase_12 AC 442 ms
256,552 KB
testcase_13 AC 436 ms
256,552 KB
testcase_14 AC 436 ms
256,552 KB
testcase_15 AC 427 ms
256,552 KB
testcase_16 AC 439 ms
256,552 KB
testcase_17 AC 447 ms
256,552 KB
testcase_18 AC 432 ms
256,552 KB
testcase_19 AC 448 ms
256,552 KB
testcase_20 AC 450 ms
256,552 KB
testcase_21 AC 453 ms
256,552 KB
testcase_22 AC 439 ms
256,552 KB
testcase_23 AC 461 ms
256,552 KB
testcase_24 AC 467 ms
256,552 KB
testcase_25 AC 449 ms
256,552 KB
testcase_26 AC 450 ms
256,552 KB
testcase_27 AC 445 ms
256,552 KB
testcase_28 AC 428 ms
256,552 KB
testcase_29 AC 430 ms
256,552 KB
testcase_30 AC 433 ms
256,544 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 449 ms
256,556 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 432 ms
256,552 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 438 ms
256,556 KB
testcase_49 WA -
testcase_50 AC 427 ms
256,552 KB
testcase_51 AC 430 ms
256,548 KB
testcase_52 AC 450 ms
256,552 KB
testcase_53 AC 441 ms
256,552 KB
testcase_54 AC 451 ms
256,552 KB
testcase_55 AC 435 ms
256,552 KB
testcase_56 AC 473 ms
256,552 KB
testcase_57 AC 451 ms
256,552 KB
testcase_58 AC 465 ms
256,552 KB
testcase_59 AC 445 ms
256,552 KB
testcase_60 AC 444 ms
256,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
    from heapq import heapify, heappop, heappush
    from bisect import bisect_left, bisect_right
    from copy import deepcopy
    import copy
    import random
    from collections import deque,Counter,defaultdict
    from itertools import permutations,combinations
    from decimal import Decimal,ROUND_HALF_UP
    #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    from functools import lru_cache, reduce
    #@lru_cache(maxsize=None)
    from operator import add,sub,mul,xor,and_,or_,itemgetter
    INF = 10**18
    mod1 = 10**9+7
    mod2 = 998244353
    
    #DecimalならPython
    #再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    '''
    
    
    
    '''
    
    #p = のところを変更すること。
    #limitationも必要なら変更
    def nCr(n, r, p):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return fact[n] * factinv[r] * factinv[n-r] % p
    
    p = mod1
    limitation = 10 ** 6  # N は必要分だけ用意する
    fact = [1, 1]  # fact[n] = (n! mod p)
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0, 1]  # factinv 計算用
    
    for i in range(2, limitation + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
    
    N,K,M = map(int, input().split())
    
    ls = []
    for i in range(1,min(N,K)+1):
        if K%i == 0:
            ls.append(i)
    
    tmp = 0
    for d in ls:
        tmp += nCr(N-1,d-1,mod1)*fact[d-1]%mod1*pow(N,N-d,mod1)%mod1
    
    if M == 1:
        print(tmp)
    else:
        ans = (pow(N,N,mod1)-tmp)*pow(N-1,mod1-2,mod1)%mod1
        print(ans)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0