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. E20180519-hm

    distinct adj. 明显的,清楚的; 卓越的,不寻常的; 有区别的; 确切的;

  2. 51nod - 1420 - 数袋鼠好有趣 - 贪心 - 二分

    https://www.51nod.com/Challenge/Problem.html#!#problemId=1420 一开始乱搞了一发,每个袋鼠二分找最小的能放它的,然后二分的范围从下一个开始保 ...

  3. TP5之查询那些事

    1.使用 model 查询,查出的类型为 对象 $a 是一个对象,使用 $a->name 的方式来获取 对象里的属性 2.使用 db 查询,查询出的是 数组 $b 是一个数组,使用 $b['na ...

  4. DP简单问题联系--最长递增子序列+最长公共子序列等

    今天重温了一下dp问题,发现自己两个礼拜不写题目就什么都不会了...心态爆炸,感觉去考试怕是要gg了... 不过今天总结一下写的题目,全部都是基础的dp问题 第一个是 求最长不下降子序列的长度 第一行 ...

  5. IT兄弟连 JavaWeb教程 Servlet会话跟踪 经典面试题

    1.描述Cookie的作用 Cookie是网站保存在浏览器客户端的信息,也就是说保存在访客的机器里的变量,一般随着HTTP头发送到客户端.在Cookie生效之后及失效之前,客户每次发出页面请求的时候, ...

  6. 48个国际音标-/iː/

    /iː/ 是单元音前元音,是个长元音. ***ee,ea,ie,ei*** 1)张开你的嘴巴,好像你在微笑,露出你的牙齿,嘴唇向两边伸开,成扁平形. 2)将舌前部向硬腭尽量抬起.舌头轻微接触下齿背部. ...

  7. mysql count 中使用case when 带条件及去重

    SELECT CASE (SELECT NOW() > '2019-02-12 16:48:00') WHEN 1 THEN '男' WHEN 2 THEN '女' ELSE '未知' END ...

  8. VLAN-4-在路由器上配置Trunk

    VLAN Trunk技术可以用在路由器和主机上,也可以用在交换机上.路由器不支持DTP,所以工程师必须手动配置. 路由器Trunk需要使用子接口(在一个接口中实现多个vlan间的路由和通信),每个子接 ...

  9. MySQL 命令(一)

    mysql 数据库:保存有组织的数据的容器.(通常是一个文件或一组文件) 表:某种特定类型数据的结构化清单.数据库中的每个表都有一个名字,用来标识自己,此名字是唯一的 列:表中的一个字段.所有表都是由 ...

  10. CVE-2012-0002(MS12-020)3389远程溢出漏洞

    1:攻击机:Kali和windows皆可 2:目标机:windows XP系统(开启3389) Kali测试: search m12-020 搜索ms12-020 use auxiliary/dos/ ...