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 ...
随机推荐
- Java判断一个数是不是快乐数
快乐数的定义: 快乐数(happy number)有以下的特性: 在给定的进位制下,该数字所有数位(digits)的平方和,得到的新数再次求所有数位的平方和,如此重复进行,最终结果必为1. 以十进制为 ...
- 解决overflow: auto在Ios中滑动不流畅
[bug]—— H5页面在 ios 端滑动不流畅的问题 IOS系统的惯性滑动效果非常6,但是当我们对div加overflow-y:auto;后是不会出这个效果的,滑动的时候会感觉很生涩.怎么办? ...
- c#二维数组传递与拷贝
定义 string[,] arr = new string[12, 31] 另一种string[][] ary = new string[5][];相当于一维数组 常量二维数组定义, 用readonl ...
- [Xcode 实际操作]八、网络与多线程-(3)使用UIApplication对象拨打电话
目录:[Swift]Xcode实际操作 本文将演示如何使用应用程序单例对象,拨打电话的功能. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] 注:需要使用真机进行测 ...
- perl C/C++ 扩展(四)
在前面三篇博客中,我们了解到如何使用c/c++ 扩展自己的perl 库,但是博主在学习过程中,对动态库或静态库的加载不是十分了解,后来自己又细挖一下.后来就有了这篇博文,再后来,没有再后来了,囧!! ...
- DB2 - 编目的解释
编目(Catalog),是在本地或远程建立客户端到服务器的数据库连接的过程.其目的在于获取编目信息,即生成用来访问数据库的目录.系统数据库目录包含一个列表和指针,通过目录可以使 DB2 能够找到已知的 ...
- C - Catch That Cow POJ - 3278
//标准bfs #include <iostream> #include <cstdio> #include <algorithm> #include <cm ...
- Tinghua Data Mining 4
贝叶斯 决策树 知道三文鱼和金枪鱼颜色 让你去猜 B命中的概率不能直接减去四分之三 因为有可能同时命中 A B 命中不是互斥事件 即便体检报告是阳性,真正得癌症的概率也很小,只有0.21 绝大多数的阳 ...
- 2017 Multi-University Training Contest - Team 1 Add More Zero
Problem Description There is a youngster known for amateur propositions concerning several mathemati ...
- mysql自己编写启停脚本
一.场景 在实际生产环境中要求相对较高的企业对于root权限管控相对比较高,故而很多软件并非安装在root用户下(当然root用户权限也可管理,但正常情况下root权限并不会给业务使用方,而会给一个普 ...