Codeforces Round #272 (Div. 2)C. Dreamoon and Sums 数学推公式
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 andy. 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
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}.
题意:给你a,b,现在对所有x满足 div(x,b)/mod(x,b) =k (1<=k<=a) 的x求和 取摸.
题解: 设y=div(x,b),z=mod(x,b),
可以得到
y=z*k,y*b+z=x,联立得
(kb+1)z=x,
下面用到求和公式,
然后假设k为常量,得到x=b(b-1)*(kb+1)/2,
最后k还原为变量,得到x=b(b-1)/2*[(1+a)a*b/2+a]
///
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
inline ll read()
{
ll x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
//****************************************
ll mod =;
#define maxn 100000+5
ll a,b;
int main(){
a=read(),b=read();
a=((b*((a*(a+)/)%mod))%mod+a)%mod;b=((b*(b-))/)%mod;
cout<<(a*b)%mod<<endl;
return ;
}
代码
Codeforces Round #272 (Div. 2)C. Dreamoon and Sums 数学推公式的更多相关文章
- 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. 2)  C. Dreamoon and Sums  (数学  思维)
		
题目链接 这个题取模的时候挺坑的!!! 题意:div(x , b) / mod(x , b) = k( 1 <= k <= a).求x的和 分析: 我们知道mod(x % b)的取值范围为 ...
 - Codeforces Round #272 (Div. 2)-C. Dreamoon and Sums
		
http://codeforces.com/contest/476/problem/C C. Dreamoon and Sums time limit per test 1.5 seconds mem ...
 - 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) 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 ...
 
随机推荐
- Fiddler—重复发送一个请求的设置
			
https://jingyan.baidu.com/article/b2c186c829a85dc46ff6ff60.html 选中一个request——>Reissue Sequentaill ...
 - HDU_1018_n(1e7)的阶乘的结果的位数
			
http://acm.hdu.edu.cn/showproblem.php?pid=1018 Big Number Time Limit: 2000/1000 MS (Java/Others) ...
 - Java线程的sleep方法
			
sleep方法的签名: public static void sleep (long millis) sleep方法是Thread类的一个方法,作用是:在指定的毫秒内让正在执行的线程休眠(暂停执行) ...
 - 14XML解析
			
XML解析 XML解析 DOM4J DOM4J是dom4j.org出品的一个开源XML解析包Dom4j是一个易用的.开源的库,用于XML,XPath和XSLT的解析及相关应用.它应用于Java平台,采 ...
 - gym101673G. A Question of Ingestion (DP)
			
题意:有最多100天 每天有一个食物量 你一开始有一个最大胃口表示你最开始能吃多少食物 如果你昨天吃了 那么今天的胃口为昨天的2/3 如果你前天吃了 昨天没吃 那么你的胃口可以恢复到前天的情况 如果你 ...
 - P1077摆花
			
传送 总共要摆m盆花,而每种花最多有a[i]盆.仔细思索,发现它是一个多重背包求方案数问题.但是我蒟蒻的不会,于是跑去问大佬. 以下状态转移方程及化简from rqy 如果第i个物品有a[i],每个的 ...
 - 10 Minutes to pandas中文版
			
本文是对pandas官方网站上<10 Minutes to pandas>的一个简单的翻译,原文在这里.这篇文章是对pandas的一个简单的介绍,详细的介绍请参考:Cookbook .习惯 ...
 - MySQL5
			
MySQL数据库5 mysqldump备份恢复数据库 冷备份还原数据库 逻辑卷快照备份还原数据库 xtrabackup备份还原数据库 1. 备份和恢复概述 适用场景 硬件故障.软件故障.自然灾害.黑客 ...
 - https报错注销源文件内容
			
open -a pycharm /Users/vivi/Library/Python/3.6/lib/python/site-packages/requests/packages/urllib3/co ...
 - jmeter录制火狐浏览器
			
昨天看youtube,居然发现有这功能,啊哈哈 听不懂英语 也能有收获. 一.Jmeter 文件中选择Templates->Recording 二.创建之后,自动出现一个模板: 1. Threa ...