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 ...
随机推荐
- [OpenGL]配置GLFW(超详细)
注:本文可转载,转载请著名出处:http://www.cnblogs.com/collectionne/p/6937644.html.本文还会修改,如果不在博客园(cnblogs)发现本文,建议访问上 ...
- js 调用栈机制与ES6尾调用优化介绍
调用栈的英文名叫做Call Stack,大家或多或少是有听过的,但是对于js调用栈的工作方式以及如何在工作中利用这一特性,大部分人可能没有进行过更深入的研究,这块内容可以说对我们前端来说就是所谓的基础 ...
- Unity AnimatorController注意事项
通过assetbundle加载的单独打包AnimatorController使用下面方法赋值 Go.GetComponent<Animator>().runtimeAnimatorCont ...
- 51nod1416(dfs)
题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1416 题意:中文题诶- 思路:dfs 搜索同一颜色的点.. 只 ...
- iOS中UIWebView使用JS交互
iOS中偶尔也会用到webview来显示一些内容,比如新闻,或者一段介绍.但是用的不多,现在来教大家怎么使用js跟webview进行交互. 这里就拿点击图片获取图片路径为例: 1.测试页面html & ...
- hdu 1695 GCD(容斥)
题目链接 #include <bits/stdc++.h> using namespace std; typedef long long ll; inline int read() { , ...
- Codeforces Round #547 (Div. 3) A.Game 23
链接:https://codeforces.com/contest/1141/problem/A 题意: 给n和m,有两种操作:将n×2 或 n×3,求最少的乘法次数由n得到m. 不能得到时为-1. ...
- hdu6318( 2018 Multi-University Training Contest 2)
bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6318 求逆序数的对数 #include<iostream> #include ...
- Sql 2000系统表 语句查询表结构
SQL2000系统表的应用 –1:获取当前数据库中的所有用户表 select Name from sysobjects where xtype=’u’ and status>=0 –2:获取 ...
- HTML实例之简单的网页布局
需求: <html> <head> <title>简单的表格网页布局</title> <meta charset="UTF-8" ...