您的位置:首页 > 其它

Codeforces 476C Dreamoon and Sums

2016-07-14 23:22 260 查看
数学题

推出数学公式后计算即可

注意用long long类型防止数据溢出
#include <iostream>//数据输入输出流
#include <string.h>//字符串操作函数
#include <stdio.h>//C的输入输出
#include <stdlib.h>//定义杂项函数及内存分配函数
#include <math.h>//C中的数学函数
#include <cstring>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor容器
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如:bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数(代替运算符)
//#include <iomanip.h>//参数化输入/输出
#include <limits.h>//定义各种数据类型最值常量
//#include <strstrea.h>//基于数组的输入/输出
//#include <fstream.h>//文件输入/输出
#define ll long long

using namespace std;

ll a, b;
int MOD = 1e9 + 7;

ll qmul ( ll x, ll y )
{
ll ret = 0;
while ( y )
{
if ( y & 1 )
ret = ( ret + x ) % MOD;
x = x * 2 % MOD;
y >>= 1;
}
return ret;
}

int main()
{
cin >> a >> b;
ll p1 = ( a * ( a + 1 ) / 2 ) % MOD;
//cout << p1 << endl;
p1 = ( p1 * b ) % MOD;
//cout << p1 << endl;
p1 = ( p1 + a ) % MOD;
//cout << p1 << endl;
ll p2 = ( b * ( b - 1 ) / 2 ) % MOD ;
//cout << p2 << endl;
ll ans = p1*p2%MOD;
cout << ans << endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  codeforces 数学