A. 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 andy.
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}.

题解:这一题能够将题目中的那个东西化简,最后变成x=(k*b+1)*(x mod b)他要求全部x的和,由于k是1~a,x mod b是1~b-1,所以我们能够直接把这个结果算出来。简单的求和就可以。

#include <iostream>
#include <cstring>
#include <cstdio> using namespace std; long long a,b; int main()
{
scanf("%I64d%I64d",&a,&b);
long long c=((b-1)*b/2)%1000000007,d=((b*(a*(a+1)/2%1000000007)+a)%1000000007);
long long ans=(c*d)%1000000007;
printf("%I64d\n",ans%1000000007);
return 0;
}

【CODEFORCES】 A. Dreamoon and Sums的更多相关文章

  1. 【CODEFORCES】 B. Dreamoon and Sets

    B. Dreamoon and Sets time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. 【CODEFORCES】 C. Dreamoon and Strings

    C. Dreamoon and Strings time limit per test 1 second memory limit per test 256 megabytes input stand ...

  3. 【Codeforces】Round #491 (Div. 2) 总结

    [Codeforces]Round #491 (Div. 2) 总结 这次尴尬了,D题fst,E没有做出来.... 不过还好,rating只掉了30,总体来说比较不稳,下次加油 A:If at fir ...

  4. 【Codeforces】Round #488 (Div. 2) 总结

    [Codeforces]Round #488 (Div. 2) 总结 比较僵硬的一场,还是手速不够,但是作为正式成为竞赛生的第一场比赛还是比较圆满的,起码没有FST,A掉ABCD,总排82,怒涨rat ...

  5. 【codeforces】【比赛题解】#931 CF Round #468 (Div. 2)

    因为太迟了,所以没去打. 后面打了Virtual Contest,没想到拿了个rank 3,如果E题更快还能再高,也是没什么想法. [A]Friends Meeting 题意: 在数轴上有两个整点\( ...

  6. 【codeforces】【比赛题解】#862 CF Round #435 (Div.2)

    这次比赛打得很舒服,莫名得了个Rank41,涨了219的Rating,就比较优秀.不过还是没有闫神厉害啊.题目链接::P. [A]MEX 题意: Evil博士把Mahmoud和Ehab绑架到了邪恶之地 ...

  7. 【CodeForces】601 D. Acyclic Organic Compounds

    [题目]D. Acyclic Organic Compounds [题意]给定一棵带点权树,每个点有一个字符,定义一个结点的字符串数为往下延伸能得到的不重复字符串数,求min(点权+字符串数),n&l ...

  8. 【Codeforces】849D. Rooter's Song

    [算法]模拟 [题意]http://codeforces.com/contest/849/problem/D 给定n个点从x轴或y轴的位置p时间t出发,相遇后按对方路径走,问每个数字撞到墙的位置.(还 ...

  9. codeforces 477A A. Dreamoon and Sums(数学)

    题目链接: A. Dreamoon and Sums time limit per test 1.5 seconds memory limit per test 256 megabytes input ...

随机推荐

  1. c语言的类型、运算符与表达式

    title: 2017-10-17c语言的类型.运算符与表达式 tags: c程序设计语言 grammar_cjkRuby: true --- 1.1 数据类型 char 字符型,一个字节 int 整 ...

  2. CLR之委托的揭秘(二)

    杂谈 在开始真正的代码之前,分析一下上周的一些工作内容,发现自己在代码上还是有很多小毛病需要纠正和去更改的,首先之前一直疏于文档的整理,几乎很少去写文档,第二对于接口开发过程中缺少一定的严谨性,很多问 ...

  3. fragmentTabHost 使用示例

    目前我们看微信的底部,有四个导航栏,那我们应该来怎么实现类似的导航栏呢? 在 android 4.0 的时候,推出了一个新的工具,fragmentTabHost . fragmentTabHost  ...

  4. Struts2初探

    我记得美妙的瞬间:在我的面前出现了你,有如昙花一现的幻影 今天写一篇Struts2框架的,在很久很久以前,Struts2可谓是称霸江湖,纵然现在有后起之秀,但Struts2依然可以成为老牌的主流框架, ...

  5. 后端自动化版本管理,再也不用改URL了!

    每次升级接口版本时,后端.前端.客户端都是痛苦的: 后端:要兼容旧版客户端,以前的接口不能动啊,又得写新接口.新文档了,唉! 前端:还好,就是版本号到处都是,改起来比较烦. Android:快点啊产品 ...

  6. maven学习之1

    最近用maven的时候各种出问题,打算系统的学习一下maven,搞明白依赖之类的. (一)创建工程: mvn archetype:generate 这样就可以根据提示来建立一个maven项目,常用的有 ...

  7. 在网页标题栏title加入图标?

    方法一:制作一个ico格式的图片,将图片命名为favicon.ico,像素大小为16*16,所使用的颜色不得超过16色,然后再把favicon.ico放到网站的根目录下就行了.这样的话浏览器会不停的搜 ...

  8. Liunx find的运用

    find命令 一.根据 -name 查找 find[搜索范围][搜索条件] find /root -name a1 若是模糊查询,则使用通配符 *匹配任意字符{find /root -name &qu ...

  9. Web登录敲门砖之sql注入

    声明:文本原创,转载请说明出处,若因本文而产生任何违法违纪行为将与本人无关.在百度.博客园.oschina.github .SegmentFault.上面都关于sql注入的文章和工具.看过很多sql注 ...

  10. CSS实现盒子高度撑开且以最高的为高

    前端开发中,常常会有需求两个盒子并排排列,高度以最高的为准,且高度是内容撑开的,类似于这样 如果不是用 table 布局,而是用 div 布局,两个子盒子浮动来实现的话,实际上默认写出来是这样的 此时 ...