【CODEFORCES】 A. Dreamoon and Sums
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 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
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}.
题解:这一题能够将题目中的那个东西化简,最后变成x=(k*b+1)*(x mod b)他要求全部x的和,由于k是1~a,x mod b是1~b-1,所以我们能够直接把这个结果算出来。简单的求和就可以。
#include <iostream>
#include <cstring>
#include <cstdio> using namespace std; long long a,b; int main()
{
scanf("%I64d%I64d",&a,&b);
long long c=((b-1)*b/2)%1000000007,d=((b*(a*(a+1)/2%1000000007)+a)%1000000007);
long long ans=(c*d)%1000000007;
printf("%I64d\n",ans%1000000007);
return 0;
}
【CODEFORCES】 A. Dreamoon and Sums的更多相关文章
- 【CODEFORCES】 B. Dreamoon and Sets
B. Dreamoon and Sets time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 【CODEFORCES】 C. Dreamoon and Strings
C. Dreamoon and Strings time limit per test 1 second memory limit per test 256 megabytes input stand ...
- 【Codeforces】Round #491 (Div. 2) 总结
[Codeforces]Round #491 (Div. 2) 总结 这次尴尬了,D题fst,E没有做出来.... 不过还好,rating只掉了30,总体来说比较不稳,下次加油 A:If at fir ...
- 【Codeforces】Round #488 (Div. 2) 总结
[Codeforces]Round #488 (Div. 2) 总结 比较僵硬的一场,还是手速不够,但是作为正式成为竞赛生的第一场比赛还是比较圆满的,起码没有FST,A掉ABCD,总排82,怒涨rat ...
- 【codeforces】【比赛题解】#931 CF Round #468 (Div. 2)
因为太迟了,所以没去打. 后面打了Virtual Contest,没想到拿了个rank 3,如果E题更快还能再高,也是没什么想法. [A]Friends Meeting 题意: 在数轴上有两个整点\( ...
- 【codeforces】【比赛题解】#862 CF Round #435 (Div.2)
这次比赛打得很舒服,莫名得了个Rank41,涨了219的Rating,就比较优秀.不过还是没有闫神厉害啊.题目链接::P. [A]MEX 题意: Evil博士把Mahmoud和Ehab绑架到了邪恶之地 ...
- 【CodeForces】601 D. Acyclic Organic Compounds
[题目]D. Acyclic Organic Compounds [题意]给定一棵带点权树,每个点有一个字符,定义一个结点的字符串数为往下延伸能得到的不重复字符串数,求min(点权+字符串数),n&l ...
- 【Codeforces】849D. Rooter's Song
[算法]模拟 [题意]http://codeforces.com/contest/849/problem/D 给定n个点从x轴或y轴的位置p时间t出发,相遇后按对方路径走,问每个数字撞到墙的位置.(还 ...
- codeforces 477A A. Dreamoon and Sums(数学)
题目链接: A. Dreamoon and Sums time limit per test 1.5 seconds memory limit per test 256 megabytes input ...
随机推荐
- 一起写框架-控制反转(Ioc)概述(二)
控制反转概述 控制反转(Inversion of Control,英文缩写为IoC),就是将代码的调用的控制权,由调用方转移给被调用方. 如图:修改代码A类的代码,才能将B类的对象换成C类.代码的控制 ...
- Scrum Meeting Alpha - 9
Scrum Meeting Alpha - 9 NewTeam 2017/11/03 地点:新主楼F座二楼 任务反馈 团队成员 完成任务 计划任务 安万贺 完成了登陆退出功能Pull Request ...
- C++使用htslib库读入和写出bam文件
有时候我们需要使用C++处理bam文件,比如取出read1或者read2等符合特定条件的序列,根据cigar值对序列指定位置的碱基进行统计或者对序列进行处理并输出等,这时我们可以使用htslib库 ...
- .Net中各种不同的对象创建方式的速度差异
在.Net中,微软给我们提供了很多不同的创建对象实例的方法,它们的速度又各有不同,以下一一列举. 使用new关键字 这在.Net中是最常见,也是速度最快的方式: ...
- 利用 WSL 在 Windows下打造高效的 Linux 开发环境
WSL-Windows Subsystem for Linux 介绍 The Windows Subsystem for Linux lets developers run Linux environ ...
- NetFlow学习笔记
NetFlow学习笔记 标签: netflow 由于工作需要,对NetFlow做了一些学习和调研,并总结成文档以供学习分享. 背景:随着系统的升级与漏洞的修补,入侵主机进而进行破坏的病毒攻击方式在攻击 ...
- 跨域请求cookie获取与设置问题
描述:最近做项目遇到了cookie的问题,项目为前后端分离项目,前台有分外网IP(A外)和内网IP(A内),后台服务只有一个内网IP(B内). 现象:当我前台异步请求发送给后台的时候,后台并不能获取到 ...
- c语言的内存分析
1. 进制 1. 什么是进制 ● 是一种计数的方式,数值的表示形式 汉字:十一 十进制:11 二进制:1011 八进制:13 ● 多种进制:十进制.二进制.八进制.十六进制.也就是说,同一个 ...
- Linux 链接详解(1)
可执行文件的生成过程: hello.c ----预处理---> hello.i ----编译----> hello.s -----汇编-----> hello.o -----链接- ...
- centos 使用 beyond compare 对比工具
我这里的环境是centos7桌面版 三条命令安装beyond compare wget http://www.scootersoftware.com/bcompare-4.2.3.22587.x86_ ...