Codeforce Round #224 Div2 B
→ Practice
You are registered for practice. You can solve problems unofficially. Results can be found in the contest status and in the bottom of standings.
1 #pragma comment(linker,"/STACK:102400000,102400000") 2 #include <cstdio> 3 #include <vector> 4 #include <cmath> 5 #include <queue> 6 #include <cstring> 7 #include <iostream> 8 #include <algorithm> 9 using namespace std; 10 #define INF 0x7fffffff 11 #define mod 1000000007 12 #define ll long long 13 #define maxn 1000025 14 #define pi acos(-1.0) 15 ll n, m, ans; 16 ll a, b, c, w, x, t, k, d, tmp; 17 int main(){ 18 cin >> a >> b >> w >> x >> c; 19 m = max(0LL, c - a); 20 tmp = b; 21 while (tmp != b || d == 0){ 22 k++; 23 if (b >= x){ 24 b -= x; 25 d++; 26 } 27 else b = w - (x - b); 28 } 29 t = max(0LL, m / d - 1); 30 m -= t*d; 31 ans += t*k; 32 while (m > 0){ 33 ans++; 34 if (b >= x){ 35 b -= x; 36 m--; 37 } 38 else b = w - (x - b); 39 } 40 cout << ans; 41 return 0; 42 }




浙公网安备 33010602011771号