http://codeforces.com/contest/476/problem/C

C. Dreamoon and Sums
time limit per test

1.5 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 ≤ 107).

Output

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

Sample test(s)
input
1 1
output
0
input
2 2
output
8
Note

For the first sample, there are no nice integers because  is always zero.

For the second sample, the set of nice integers is {3, 5}.

解题思路:可推出公式 ans =  

 1 #include <stdio.h>
 2 #include <math.h>
 3 
 4 #define ll long long
 5 
 6 int main(){
 7     ll a, b, k, ans, x, y;
 8     ll MOD = 1e9 + ;
 9     while(scanf("%I64d %I64d", &a, &b) != EOF){
         ans = ;
         for(k = ; k <= a; k++){
             x = (k * b + ) % MOD;
             y = (b * (b - ) / ) % MOD;
             ans += x * y % MOD;
         }
         printf("%I64d\n", ans % MOD);
     }
     return ;

19 }

Codeforces Round #272 (Div. 2)-C. Dreamoon and Sums的更多相关文章

  1. Codeforces Round #272 (Div. 2)C. Dreamoon and Sums 数学推公式

    C. Dreamoon and Sums   Dreamoon loves summing up something for no reason. One day he obtains two int ...

  2. Codeforces Round #272 (Div. 2) C. Dreamoon and Sums 数学

    C. Dreamoon and Sums time limit per test 1.5 seconds memory limit per test 256 megabytes input stand ...

  3. Codeforces Round #272 (Div. 1) A. Dreamoon and Sums(数论)

    题目链接 Dreamoon loves summing up something for no reason. One day he obtains two integers a and b occa ...

  4. Codeforces Round #272 (Div. 2) C. Dreamoon and Sums (数学 思维)

    题目链接 这个题取模的时候挺坑的!!! 题意:div(x , b) / mod(x , b) = k( 1 <= k <= a).求x的和 分析: 我们知道mod(x % b)的取值范围为 ...

  5. Codeforces Round #272 (Div. 2) E. Dreamoon and Strings 动态规划

    E. Dreamoon and Strings 题目连接: http://www.codeforces.com/contest/476/problem/E Description Dreamoon h ...

  6. Codeforces Round #272 (Div. 2) D. Dreamoon and Sets 构造

    D. Dreamoon and Sets 题目连接: http://www.codeforces.com/contest/476/problem/D Description Dreamoon like ...

  7. Codeforces Round #272 (Div. 2) B. Dreamoon and WiFi dp

    B. Dreamoon and WiFi 题目连接: http://www.codeforces.com/contest/476/problem/B Description Dreamoon is s ...

  8. Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs 水题

    A. Dreamoon and Stairs 题目连接: http://www.codeforces.com/contest/476/problem/A Description Dreamoon wa ...

  9. Codeforces Round #272 (Div. 2) E. Dreamoon and Strings dp

    题目链接: http://www.codeforces.com/contest/476/problem/E E. Dreamoon and Strings time limit per test 1 ...

随机推荐

  1. IOS Carthage安装、使用

    一.Carthage的安装和使用1.安装homebrew后输入如下命令 $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercont ...

  2. CF 429B B.Working out 四个角递推

    B. Working outtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutpu ...

  3. Weekly Contest 78-------->809. Expressive Words (stack)

    Sometimes people repeat letters to represent extra feeling, such as "hello" -> "he ...

  4. 51nod 1049【经典】

    自己模拟,全靠体会~ #include <cstdio> #include <stack> #include <iostream> #include <str ...

  5. hyperledger fabric 1.0.5 分布式部署 (五)

    梳理fabric e2e_cli 测试程序的具体步骤 作者在 hyperledger fabric 1.0.5 分布式部署 (一)中给读者们介绍了如何从零开始部署一个测试的 demo 环境,如果细心的 ...

  6. (转) Git

    http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

  7. css margin padding 四个方向

    margin 和padding虽然有四个单独的方向属性,如margin-left,padding-bottom等等. 但是可以用margin:2px 3px 4px 5px     四个参数的含义:上 ...

  8. 基于SpringBoot+MyBatis实现一套电商系统

    项目介绍 mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现. 前台商城系统包含首页门户.商品推荐.商品搜索.商品展示.购物车.订单流程.会员中心 ...

  9. localStorage和sessionStorage使用

    localStorage.setItem("key","value");//存数据 localStorage.getItem("key"); ...

  10. iOS 同一个View识别单击和双击手势

    1.给View添加手势 //view添加两个手势检测方法 self.currentPlayerView.userInteractionEnabled = YES; UITapGestureRecogn ...