-
Notifications
You must be signed in to change notification settings - Fork 216
Expand file tree
/
Copy path203A - Two Problems.cpp
More file actions
42 lines (38 loc) · 851 Bytes
/
Copy path203A - Two Problems.cpp
File metadata and controls
42 lines (38 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//4172437 Jul 27, 2013 5:48:18 AM fuwutu 203A - Two Problems GNU C++0x Accepted 30 ms 0 KB
#include <iostream>
using namespace std;
int main()
{
int x, t, a, b, da, db;
cin >> x >> t >> a >> b >> da >> db;
if (x == 0)
{
cout << "YES" << endl;
return 0;
}
if (x == 0
|| (x <= a && x > a - da * t && (a - x) % da == 0)
|| (x <= b && x > b - db * t && (b - x) % db == 0))
{
cout << "YES" << endl;
return 0;
}
for (int pa = a, pb = b - db * (t - 1); pa > a - da * t && pb <= b; )
{
if (pa + pb > x)
{
pa -= da;
}
else if (pa + pb < x)
{
pb += db;
}
else
{
cout << "YES" << endl;
return 0;
}
}
cout << "NO" << endl;
return 0;
}