[HDOJ5417]Victor and Machine

 1 #include <cstdio>
 2 #include <cstdlib>
 3 #include <cstring>
 4 #include <algorithm>
 5 #include <iostream>
 6 #include <cmath>
 7 #include <queue>
 8 #include <deque>
 9 #include <map>
10 #include <stack>
11 #include <list>
12 #include <vector>
13 #include <ctime>
14 
15 using namespace std;
16 
17 int x,y,w,n;
18 
19 int main(){    
20     while(~scanf("%d%d%d%d", &x, &y, &w, &n)) {
21         int t;
22         int ans = 1;
23         int cnt = 1;
24         while(1) {
25             if(cnt == n) {
26                 break;
27             }
28             t = ans % (x + y);
29             if(t == 0) {
30                 cnt++;
31             }
32             else if(t <= x && x >= w && t % w == 0) {
33                 cnt++;
34             }
35             ans++;
36         }
37         printf("%d
", ans - 1);
38     }
39     return 0;
40 }
 
原文地址:https://www.cnblogs.com/kirai/p/4751254.html