2013 - ECJTU 暑期训练赛第七场-problem-G
2013-08-07 18:27
525 查看
G -
O.O
Crawling in process...
Crawling failed
Time Limit:2000MS
Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Submit
Status
Practice
CodeForces 18B
Description
In one one-dimensional world there are
n platforms. Platform with index
k (platforms are numbered from 1) is a segment with coordinates
[(k - 1)m, (k - 1)m + l], and
l < m. Grasshopper Bob starts to jump along the platforms from point
0, with each jump he moves exactly
d units right. Find out the coordinate of the point, where Bob will fall down. The grasshopper falls down, if he finds himself not on the platform, but if he finds himself on the edge of the platform, he doesn't fall down.
Input
The first input line contains 4 integer numbers
n, d,
m, l (1 ≤ n, d, m, l ≤ 106, l < m) — respectively: amount of platforms,
length of the grasshopper Bob's jump, and numbers m and
l needed to find coordinates of the
k-th platform: [(k - 1)m, (k - 1)m + l].
Output
Output the coordinates of the point, where the grosshopper will fall down. Don't forget that if Bob finds himself on the platform edge, he doesn't fall down.
Sample Input
Input
Output
Input
Output
O.O
Crawling in process...
Crawling failed
Time Limit:2000MS
Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Submit
Status
Practice
CodeForces 18B
Description
In one one-dimensional world there are
n platforms. Platform with index
k (platforms are numbered from 1) is a segment with coordinates
[(k - 1)m, (k - 1)m + l], and
l < m. Grasshopper Bob starts to jump along the platforms from point
0, with each jump he moves exactly
d units right. Find out the coordinate of the point, where Bob will fall down. The grasshopper falls down, if he finds himself not on the platform, but if he finds himself on the edge of the platform, he doesn't fall down.
Input
The first input line contains 4 integer numbers
n, d,
m, l (1 ≤ n, d, m, l ≤ 106, l < m) — respectively: amount of platforms,
length of the grasshopper Bob's jump, and numbers m and
l needed to find coordinates of the
k-th platform: [(k - 1)m, (k - 1)m + l].
Output
Output the coordinates of the point, where the grosshopper will fall down. Don't forget that if Bob finds himself on the platform edge, he doesn't fall down.
Sample Input
Input
2 2 5 3
Output
4
Input
5 4 11 8
Output
20
这题每次考虑跳台边缘就行了
AC代码:
#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> #include<cmath> #include<iomanip> const int MAX=100001; int x[MAX]; int y[MAX]; using namespace std; int main() { __int64 n,d,m,l,i,p,q; double k1,k2; cin>>n>>d>>m>>l; q=0; for(i=0;i<n-1;i++) { if((i*m+l)/d*d+d<(i+1)*m) break; } cout<<((i*m+l)/d*d+d)<<endl; return 0; }
相关文章推荐
- 2013 - ECJTU 暑期训练赛第七场-problem-H
- 2013 - ECJTU 暑期训练赛第七场-problem-G
- 2013 - ECJTU 暑期训练赛第七场-problem-A
- 2013 - ECJTU 暑期训练赛第七场-problem-F
- 2013 - ECJTU 暑期12级训练赛第一场-Problem-A
- 2013 - ECJTU 暑期训练赛第五场-problem-F
- 2013 - ECJTU 暑期12级训练赛第一场-problem-B
- 2013 - ECJTU 暑期12级训练赛第一场-problem-C
- 2013 - ECJTU 暑期训练赛第三场-problem-F
- 2013 - ECJTU 暑期12级训练赛第一场-problem-E
- 2013 - ECJTU 暑期训练赛第二场-problem-A
- 2013 - ECJTU 暑期训练赛第四场-problem-A
- 2013 - ECJTU 暑期训练赛第六场-problem-F
- 2013 - ECJTU 暑期训练赛第二场-problem-E
- 2013 - ECJTU 暑期训练赛第六场-problem-G
- 2013 - ECJTU 暑期训练赛第二场-problem-G
- 2013 - ECJTU 暑期训练赛第三场-problem-J
- 2013 - ECJTU 暑期训练赛第二场-problem-H
- 2013 - ECJTU 暑期12级训练赛第一场-Problem-H
- 2013 - ECJTU 暑期训练赛第四场-problem-C