Codeforces 382 B. Number Busters(数论推公式)
来源:互联网 发布:动态加载js 完成 编辑:程序博客网 时间:2024/04/29 23:44
Arthur and Alexander are number busters. Today they've got a competition.
Arthur took a group of four integers a, b, w, x (0 ≤ b < w, 0 < x < w) and Alexander took integer с. Arthur and Alexander use distinct approaches to number bustings. Alexander is just a regular guy. Each second, he subtracts one from his number. In other words, he performs the assignment: c = c - 1. Arthur is a sophisticated guy. Each second Arthur performs a complex operation, described as follows: if b ≥ x, perform the assignment b = b - x, if b < x, then perform two consecutive assignments a = a - 1; b = w - (x - b).
You've got numbers a, b, w, x, c. Determine when Alexander gets ahead of Arthur if both guys start performing the operations at the same time. Assume that Alexander got ahead of Arthur if c ≤ a.
The first line contains integers a, b, w, x, c (1 ≤ a ≤ 2·109, 1 ≤ w ≤ 1000, 0 ≤ b < w, 0 < x < w, 1 ≤ c ≤ 2·109).
Print a single integer — the minimum time in seconds Alexander needs to get ahead of Arthur. You can prove that the described situation always occurs within the problem's limits.
4 2 3 1 6
2
4 2 3 1 7
4
1 2 3 2 6
13
1 1 2 1 1
0
#include<iostream>#include<cstdio>#include<cmath>#define LL long longusing namespace std;int main(){ LL a,b,w,x,c; scanf("%lld%lld%lld%lld%lld",&a,&b,&w,&x,&c); if(c<=a) printf("0\n"); else { LL p1=(c-a-b/x)*x-b%x; LL p2=w-x; LL p; if(p1%p2==0) p=p1/p2; else p=p1/p2+1; printf("%lld\n",p+c-a); } return 0;}要是还有哪里不明白欢迎提出来,欢迎各位大神们提出错误
- Codeforces 382 B. Number Busters(数论推公式)
- codeforces 382 B Number Busters(推公式)
- Codeforces 382B Number Busters(数论)
- CodeForces 382B Number Busters(数论-数学推理)
- Codeforces 382 B. Number Busters
- CodeForces 382 B.Number Busters(鸽巢定理)
- codeforces 224 B. Number Busters
- codeforces 382B B. Number Busters [二分答案+数学]【思维】
- CF 382B Number Busters
- CF contest/382/B. Number Busters
- B. Number Busters
- B. Number Busters----数学推演
- POJ-3604(数论题目,推公式)
- CF 224DIV2 B Number Busters
- cf——B. Number Busters
- hdu6198 number number number(递推公式黑科技)
- Number Busters
- CodeForces 236B - Easy Number Challenge(数论:求因子个数)
- Java Sax解析xml
- H2 database 安装与使用
- 常用js技巧(有点长)
- [leetcode] Binary Tree Maximum Path Sum
- 二十九:微信公众平台开发-应用实例之人脸检测
- Codeforces 382 B. Number Busters(数论推公式)
- 【VB版机房收费】权限关系
- 【HDU1439Cipher】循环群
- 网络数据传递之数据的发送
- FrameBuffer初探
- hdu 1754 I Hate It (树状数组版)
- 5.6-奇偶位互相交换
- 《Maven实战》读书笔记
- 在Fragment中加载布局后使用findViewById出现空指针错误