Codeforces 476C Dreamoon and Sums (水
题目链接:点击打开链接
题意:
给定a,b
对于一个数x。若x是nice number,则满足(x/b)/(x%b) == [1,a](即结果在1-a之间)
问:
输出一个数表示 全部nice number的和。
推一推公式就好。。
结果就是
b*(b-1)/2 * (a + b*( (1+a)*a/2 ) )
#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
template <class T>
inline bool rd(T &ret) {
char c; int sgn;
if(c=getchar(),c==EOF) return 0;
while(c!='-'&&(c<'0'||c>'9')) c=getchar();
sgn=(c=='-')?-1:1;
ret=(c=='-')? 0:(c-'0');
while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
ret*=sgn;
return 1;
}
template <class T>
inline void pt(T x) {
if (x <0) {
putchar('-');
x = -x;
}
if(x>9) pt(x/10);
putchar(x%10+'0');
}
using namespace std;
typedef long long ll;
#define N 200010
const ll mod = 1000000007; ll a, b; int main() {
while(cin>>a>>b){
ll ans = (a*(1+a))/2; ans %= mod;
ans *= b; ans %= mod;
ans += a; ans %= mod;
ll B = b*(b-1)/2 % mod;
ans *= B; ans %= mod;
cout<<ans<<endl;
}
return 0;
}
Codeforces 476C Dreamoon and Sums (水的更多相关文章
- codeforces 476C.Dreamoon and Sums 解题报告
题目链接:http://codeforces.com/problemset/problem/476/C 题目意思:给出两个数:a 和 b,要求算出 (x/b) / (x%b) == k,其中 k 的取 ...
- codeforces 477A A. Dreamoon and Sums(数学)
题目链接: A. Dreamoon and Sums time limit per test 1.5 seconds memory limit per test 256 megabytes input ...
- 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. 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】 A. Dreamoon and Sums
A. 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 数学推公式
C. Dreamoon and Sums Dreamoon loves summing up something for no reason. One day he obtains two int ...
- cf(#div1 A. Dreamoon and Sums)(数论)
A. Dreamoon and Sums time limit per test 1.5 seconds memory limit per test 256 megabytes input stand ...
- 【Codeforces 476C】Dreamoon and Sums
[链接] 我是链接,点我呀:) [题意] 让你求出所有x的和 其中 (x div b)是(x mod b)的倍数 且x mod b不等于0 且(x div b)除(x mod b)的值(假设为k),k ...
- Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs 水题
A. Dreamoon and Stairs 题目连接: http://www.codeforces.com/contest/476/problem/A Description Dreamoon wa ...
随机推荐
- 二分+Dfs【p1902】刺杀大使
题目描述--->p1902 刺杀大使 题意概括: 找一条路径,使得从第1行到第n行路径的最大值最小. 分析: 题目概括出来,很容易想到二分. 求最大值最小,因此我们可以对最大伤害值进行二分. 如 ...
- POJ 2311 Cutting Game (Multi-Nim)
[题目链接] http://poj.org/problem?id=2311 [题目大意] 给出一张n*m的纸,每次可以在一张纸上面切一刀将其分为两半 谁先切出1*1的小纸片谁就赢了, [题解] 如果切 ...
- POJ 2112 Optimal Milking(二分图匹配)
[题目链接] http://poj.org/problem?id=2112 [题目大意] 给出一些挤奶器,每台只能供给M头牛用,牛和挤奶器之间有一定的距离 现在要让每头牛都挤奶,同时最小化牛到挤奶器的 ...
- “DllRegisterServer的调用失败”问题解决办法(转)
在日常的工作中,用regsvr32 命令注册dll组件是,会碰到模块"xxx.dll"已加载,但DllRegisterServer的调用失败.特别是再在xp的系统上能正确注册,但是 ...
- 怎样用bat批量重命名文件夹和文件
很早以前本人写过重命名文件夹的文章,发现其中稍有不完善的地方,其主要功能在文件夹名前统一加上字符,或者在文件夹名后统一加上字符,有网友反应功能太单一.今天我又仔细研究了一下bat批处理代码,分别能完全 ...
- openstack 动态加载usb,需要修改kvm虚拟机的xml文件
一.利用libvirt命令动态挂载 在利用KVM的虚拟桌面应用中,有时候需要在虚拟桌面起来后还能够动态的挂载或卸载数据盘,以达到类似热插盘U盘或移动硬盘的效果,当然管理上需要做处理.如果纯粹中技术上来 ...
- nginx和selinux冲突
cat /var/log/audit/audit.log |grep nginx |grep denied| audit2allow -M mynginx 取出selinux中有关于nginx被拒绝的 ...
- postprocessing stack v2
用了v2和unity2017.3.0f有兼容性问题 在assetbundle的情况下 CopyStd这个shader打不进去 在assetbundle的menafest里面有列但是shader.fin ...
- NYOJ 1058 部分和问题 【DFS】
部分和问题 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描写叙述 给定整数a1.a2........an,推断能否够从中选出若干数.使它们的和恰好为K. 输入 首先,n和k ...
- 一种让UITableView的数据从下往上增长的方式
遇到问题 一般来说tableview的数据都是从上往下增长,如下图所示(先是aaa出现在表格列表的最顶部,然后bbb出现在aaa的下面,以此类推) 但是如果我们想反向这个过程该怎么做呢?如下图所示(先 ...