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 ...
随机推荐
- SPOJ130 【DP·背包选取特性】
题意: 给你n个任务,每个任务有一个起始时间,持续时间,一个权值: 问你怎么分配得到最大值 思路: 数据好大..百度了一发意识到自己好菜啊!背包的特性. dp[i]代表前 i 个能构成的最大值. 对于 ...
- Lightoj1015【基础题】
题意: 计算输入数>0的所有和: 思路: 直接干... #include<cstdio> #include<queue> #include<map> #inc ...
- laravel定义全局变量并输出(实例)
在config目录创建一个 bl.php ,内容如下 <?php return [ 'IND' => "1321232", 'das' => "奥术大师 ...
- 計蒜客/數正方形(dp)
題目鏈接:https://nanti.jisuanke.com/t/44 題意:中文題誒~ 思路: 用dp[i][j]存儲以(i, j)爲左上定點的最大正方形變長,從右下角網左上角一次計算所有頂點: ...
- uoj#269. 【清华集训2016】如何优雅地求和(数论)
传送门 首先,如果\(f(x)=1\),那么根据二项式定理,有\(Q(f,n,k)=1\) 当\(f(x)=x\)的时候,有\[Q=\sum_{i=0}^ni\times \frac{n!}{i!(n ...
- js框架:jQuery
· jQuery是一个轻量级的“写的少,做的多”的JavaScript函数库(jQuery版本2以上不支持IE6,7,8) · jQuery 的功能概括: 1.html 的元素选取 2.html的元素 ...
- 关于java和python同时使用rabbitmq时队列同名问题的探讨
问题引出: 我们知道,进程之间是不能直接通信的,但是今天学习rabbitmq时发现一个奇怪的问题,即当我开启rabbitmq,用java写好的代码给rabbitmq发送完消息后并没有急着使用java去 ...
- 大数加法 HDU 1002
#include <iostream> #include <cstring> #include <string> #include <cstdio> # ...
- 模拟ssh、黏包、hashlib模块(MD5)
待补充..... 一.模拟ssh 二.黏包 1.黏包现象 让我们基于tcp先制作一个远程执行命令的程序(命令ls -l ; lllllll ; pwd) res=subprocess.Popen(cm ...
- 530 Minimum Absolute Difference in BST 二叉搜索树的最小绝对差
给定一个所有节点为非负值的二叉搜索树,求树中任意两节点的差的绝对值的最小值.示例 :输入: 1 \ 3 / 2输出:1解释:最小绝对差为1,其中 2 和 1 的差的绝对值为 ...