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 ...
随机推荐
- E20181030-hm
conquer vt. 征服; 克服; 攻克; 打败(敌人); vi. 得胜,胜利; recur vi. 复发; 重现; 再发生; 回想; recurrence n. 复回,重现; 反复,隐现; ...
- laravel 报错htmlspecialchars() expects parameter 1 to be string, object given
翻译过来就是 期望参数1是字符串 意思就是说变量为数组,应以数组的方式输出 @foreach($xxx as $k=>$y) {{$k}}{{$y}} @endforeach
- 11-1模拟赛 By cellur925
期望得分:70+100+60 实际得分:70+20+60 \(qwq\). T1:有一个 \(n\) × \(n\) 的 \(01\) 方格, 图图要从中选出一个面积最大的矩形区域, 要求这个矩形区域 ...
- SpringBoot整合Memached
一.Memached介绍 Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站 ...
- slice方法可以将“类似数组的对象”变成真正的数组 (遇到时候再研究一次)
典型的“类似数组的对象”是函数的arguments对象,以及大多数 DOM 元素集,还有字符串. // arguments对象 function args() { return arguments } ...
- 自动化脚本- 安装更换Python3.5
本脚本所有信息: 1:判断是不是root用户,是则继续不是则退出脚本输出信息2:定义自己的版本3:根据用户输入的版本号,来下载对应的版本包4:使用系统命令wget来下载,注意wet后面有一个空格5:o ...
- C# 基础之字段与属性
1.属性是字段的扩展 2.根据面向对象封装思想,字段最好设为private(私有),这样有利于防止客户端对字段的篡改,从而保证了成员的完整性 3.访问类中私有字段,C#提供了属性,用来对字段进行灵活的 ...
- nginx和uwsgi的区别和作用
Django+uwsgi+nginx nginx和uwsgi的区别和作用: 1, nginx是对外的服务器,外部浏览器通过url访问nginx, uwsgi是对内的服务器,主要用来处理动态请求. 2, ...
- 牛客练习赛42B(异或的性质)
传送门 b^ c >= b - c,这个结论应该记住,我还在这里证过…… 这个题就用到了这个结论,假如当前答案集合为S,和为a,异或和为b,当前答案为a+b了.这时又读入个c,该不该加进来?a ...
- python入门之正则表达式
正则 通过re模块实现 eg:>>>import re >>>re.findall('abc',str_name) 在strname里面完全匹配字符串 ...