TouchStone
  Please Login
Login Sign Up
距离明年CSP第一轮: ??天 距离CSP第二轮: ??天 距离NOIP还有: ??天
 Homepage  Problem Set  Examinations  Submissions  Discussions  Statistics
  • Home
  • Problem Set
  • P4360
  • Problem
  • P4360于神之怒加强版
    Limits : Time Limit : - MS   Memory Limit : - KB
    Judgment Tips : Time Limit: 5 Sec Memory Limit: 512 MB
    Description

    给下N,M,K.求

    Input Format

    输入有多组数据,输入数据的第一行两个正整数T,K,代表有T组数据,K的意义如上所示,下面第二行到第T+1行,每行为两个正整数N,M,其意义如上式所示。

    Output Format

    如题

    Sample Input 1

    1 2
    3 3 

    Sample Output 1

    20

    Sample Input 2

    10 2629945
    1360077 2479155
    4287271 4005817
    3354494 2962775
    974840 359019
    916757 4385564
    4117619 3287685
    3619635 1437025
    3417222 2797470
    4916910 790427
    4467639 4970790

    Sample Output 2

    577904688
    919020468
    544753911
    916419384
    120402745
    741218022
    295439497
    912466175
    771403005
    286364737

    Hint

    1<=N,M,K<=5000000,1<=T<=2000


    Source  bzoj 4407