Codeforces 476C Dreamoon and Sums
来源:互联网 发布:宫颈癌疫苗副作用 知乎 编辑:程序博客网 时间:2024/05/22 05:16
By we denote thequotient of integer division of x and y. By we denote theremainder 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}.
解题思路:这题就是一个简单的推导公式的题目,将x%b=1-->b-1和a=1-->a所有情况算出的x值加起来,注意横线代表的是div(x,b)%mod(x,b)必须等于0,不要和计算机中的除法弄混了,这题公式一会儿推导出来了,就是把该除法当成计算机中的除法,然后导致各种WA,最后此发现自己脑残了,mark以下,下次遇到这种情况得注意。
/* ***********************************************Author :sponge_wxyCreated Time :2015年09月06日 星期日 09时49分38秒File Name :476C.cpp************************************************ */#include <cmath>#include <ctime>#include <cstdio>#include <cstdlib>#include <cstring>#include <cctype>#include <iostream>#include <string>#include <vector>#include <deque>#include <list>#include <queue>#include <stack>#include <map>#include <set>#include <utility>#include <numeric>#include <algorithm>#include <functional>using namespace std;typedef long long ll;const int inf = 0x3f3f3f3f;const ll INF = 0x3f3f3f3f3f3f3f3fLL;const double pi = acos(-1.0);const int mod = 1000000000 + 7;ll cal_one(ll x) {return (x + 1) * x / 2;}ll cal_two(ll x) {return x * (x + 1) * (2 * x + 1) / 6;}int main() {ll a, b;cin >> a >> b;//ll x = b * cal_two(b-1);//ll y = b * (cal_two(b-1)-cal_one(b-1))/2 + cal_two(b-1);//cout << cal_one(a) * x + a * y << endl;//cout << cal_one(a) * (cal_two(b-1) + a * (cal_two(b-1)-cal_one(b-1))/2) << endl;/* * int ans = 0;for(int k = 1; k <= a; ++k) {for(int y = 1; y < b; ++y) {ans += k * b * y * y + cal_one(y-1) * b + y * y;}}printf("%d\n", ans);*/ll ans = 1;ans = ans * b * (b - 1) / 2;ans %= mod;ll t = (1+a)*a/2;t %= mod;t = b * t % mod;t += a;ans = ans * t % mod;cout << ans << endl;//ans = ans * (a + b*((1+a)*a/2)%mod) % mod;//cout << ans << endl;return 0;}
- Codeforces 476C. Dreamoon and Sums
- codeforces 476C Dreamoon and Sums
- Codeforces 476C Dreamoon and Sums (水
- codeforces 476c Dreamoon and Sums
- codeforces 476c Dreamoon and Sums
- Codeforces 476C Dreamoon and Sums
- Codeforces 476C Dreamoon and Sums
- Codeforces 476C Dreamoon and Sums【思维】
- Dreamoon and Sums CodeForces - 476C
- CF 476C Dreamoon and Sums[数学]
- Code Forces 476C Dreamoon and Sums
- 【CODEFORCES】 A. Dreamoon and Sums
- C. Dreamoon and Sums(Codeforces Round #272)
- 【Codeforces】 477A Dreamoon and Sums
- Codeforces Round #272 (Div. 2) C Dreamoon and Sums(数学)
- 【CODEFORCES】 C. Dreamoon and Strings
- Dreamoon and Sums 数学
- 477 A. Dreamoon and Sums
- hibernate3第六章之性能优化相关几个问题_2事务隔离机制
- Layer的锚点与Scale缩放
- Java中ArrayList类的用法
- AtomicBoolean介绍与使用
- unity survival shooter ZSpace
- Codeforces 476C Dreamoon and Sums
- activity工作流
- [杂记]一些感悟,随时更新
- 在VMware的Ubuntu虚拟机上安装伪分布模式的Hadoop
- 【C++】编译链接过程
- 记录在windows10用git和github管理项目
- Android开发资料
- 唯一分解
- 汉诺塔的java 实现