Codeforces Round #272 (Div. 2)-C. Dreamoon and Sums
http://codeforces.com/contest/476/problem/C
1.5 seconds
256 megabytes
standard input
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?
The single line of the input contains two integers a, b (1 ≤ a, b ≤ 107).
Print a single integer representing the answer modulo 1 000 000 007 (109 + 7).
1 1
0
2 2
8
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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #272 (Div. 2) C. Dreamoon and Sums (数学 思维)
题目链接 这个题取模的时候挺坑的!!! 题意:div(x , b) / mod(x , b) = k( 1 <= k <= a).求x的和 分析: 我们知道mod(x % b)的取值范围为 ...
- Codeforces Round #272 (Div. 2) E. Dreamoon and Strings 动态规划
E. Dreamoon and Strings 题目连接: http://www.codeforces.com/contest/476/problem/E Description Dreamoon h ...
- Codeforces Round #272 (Div. 2) D. Dreamoon and Sets 构造
D. Dreamoon and Sets 题目连接: http://www.codeforces.com/contest/476/problem/D Description Dreamoon like ...
- 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 ...
- Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs 水题
A. Dreamoon and Stairs 题目连接: http://www.codeforces.com/contest/476/problem/A Description Dreamoon wa ...
- 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 ...
随机推荐
- Mac下intellij IDEA新建javaweb项目
intellij IDEA可以说是非常好用的工具,本人用来开发java.比eclipse等好用太多了.谁用谁知道,当然只是开发工具而已,用什么都无所谓.大牛们都用记事本编程呢. 本文帮助新手创建一个j ...
- 一张图入门git系列
github地址:https://github.com/521xueweihan/git-tips
- Lightoj 1147【DP】
题意: 把n个人分成两部分,要你怎么分使得两部分尽可能相等: 思路: 如果我们把一部分人的重量达到离sum/2最近,那就一定行啊 其实就是一条棒,两种不同的棒去拼接成一条棒,然后最好就是离mid最近, ...
- 网络工程师HCNA认证学习笔记Day1
企业网络 企业网络远程互联是广域网WAN互联,而非互联网Internet小型企业网络:一个路由器.交换机.AP大型企业网络:核心层.汇聚层.接入层.考虑可用性.稳定性.扩展性.安全性.可管理,冗余. ...
- shell学习(7)- linux权限管理及修改权限命令chmod
文件系统权限基本介绍 1.文件基本权限 总共10个字符,可以分为四组, 第一组,就一个字符-,代表是文件类型,是一个常规文件,还有其他的类型如下所示 d--目录 l--符号链接,软连接 c--字符专门 ...
- redis开发小结
随着缓存在web服务中用的越来越广泛,redis可以说成为了目前最流行的NoSQL数据库!redis与memcached最大的不同在于redis支持更多的数据类型,包括string.hash.list ...
- UVA-11584:Partitioning by Palindromes(基础DP)
今天带来一个简单的线性结构上的DP,与上次的照明系统(UVA11400)是同一种类型题,便于大家类比.总结.理解,但难度上降低了. We say a sequence of characters is ...
- springMVC-数据传递
1. 使用Model.ModelAndView传递数据 注意事项: 1. redirect的数据传递 Model与ModelAndView的传递效果是一样的,且传递是数据不能是引用类型. ...
- elasticsearch的模糊查询
https://blog.csdn.net/a772304419/article/details/78951561
- matlab各向异性扩散滤波
主要是用来平滑图像的,克服了高斯模糊的缺陷,各向异性扩散在平滑图像时是保留图像边缘的(和双边滤波很像). 通常我们有将图像看作矩阵的,看作图的,看作随机过程的,记得过去还有看作力场的. 这次新鲜,将图 ...