提交时间:2023-08-09 14:20:42
运行 ID: 81511
#include<bits/stdc++.h> using namespace std; double k; double x, y; double p, q; int ans = 0; int a[100010]; int b[100010]; int main() { cin >> k; cin >> x >> y; cin >> p >> q; int dw = k / (x + y);//dw=2 int axm = k / (p + q);//dw=3 for (int i = 1; i <= k; i += (x + y))//i = 0, i = 5, i = 10 { for (int j = i; j <= i + x - 1; j++)//j = 1, j = 2, j = 3 { a[j] = 1; } for (int j = i + x; j <= i + x + y - 1; j++)//j = 4, j = 5 { a[j] = 0; } } for (int i = 1; i <= k; i += (p + q)) { for (int j = i; j <= i + p - 1; j++) { b[j] = 1; } for (int j = i + p; j <= i + p + q - 1; j++) { b[j] = 0; } } for (int i = 1; i <= k; i++) { if (a[i] == 0 && b[i] == 0) { ans += 1; } } cout << ans; return 0; }