zoukankan      html  css  js  c++  java
  • Codeforces 476C. Dreamoon and Sums

    Dreamoon loves summing up something for no reason. One day he obtains two integers a and b occasionally. He wants to calculate the sum of all nice integers. Positive integer x is called nice if  and , where k is some integer number in range [1, a].

    By  we denote the quotient of integer division of x and y. By  we denote the remainder of integer division of x and y. You can read more about these operations here: http://goo.gl/AcsXhT.

    The answer may be large, so please print its remainder modulo 1 000 000 007 (109 + 7). Can you compute it faster than Dreamoon?

    Input

    The single line of the input contains two integers ab (1 ≤ a, b ≤ 10^7).

    Output

    Print a single integer representing the answer modulo 1 000 000 007 (10^9 + 7).

    设x = k1b + k2

    那么可以得到 k1 = kk2

    所以 x = kk2b + k2 

    就是求出所有x的和

    已知k2范围,b,k范围,简单的求和

    PS:最近开始用Python练习

    a = input()
    a = a.split()
    a,b = int(a[0]),int(a[1])
    
    k2 = b*(b-1)*a // 2 
    k = (b-1)*b//2 * b* (1+a)*a // 2
    res = (k + k2) % 1000000007
    print(res)
    View Code
  • 相关阅读:
    mysql日期默认值格式('0000-00-00')错误解决
    休闲一下-精华-IMDB评分8分左右影片400多部!
    开机动画流程
    SystemServer启动服务
    理解Android进程创建流程
    android开机动画启动流程
    Android系统的启动优化
    Android 系统启动(init,zygote)
    Zygote
    init
  • 原文地址:https://www.cnblogs.com/ToTOrz/p/7853237.html
Copyright © 2011-2022 走看看