Pagini recente » Cod sursa (job #1397012) | Cod sursa (job #1358250) | Cod sursa (job #3192359) | Cod sursa (job #526115) | Cod sursa (job #1744264)
#include <fstream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
ifstream cin("plus.in");
ofstream cout("plus.out");
int main() {
long long s, x1, y1, x2, y2, x3, y3;
cin >> s >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
long long max2 = max(x2 * y2, (long long)0);
long long max3 = max(x3 * y3, (long long)0);
long long min2 = min(x2 * y2, (long long)0);
long long min3 = min(x3 * y3, (long long)0);
long long answer = 0;
for (long long i = 0; i <= x1; i++) {
if (y2 == 0) {
if (y3 == 0 && s == 0)
answer = answer + (x2 + 1) * (x3 + 1);
else
if (y3 != 0) {
if (s / y3 <= x3 && s / y3 >= 0)
answer = answer + x2 + 1;
}
}
else
if (y3 == 0) {
if (s / y2 <= x2 && s / y2 >= 00)
answer = answer + x3 + 1;
}
else
answer = answer + max((long long)0, min(s - min2, max3) - max(s - max2, min3) + 1);
s -= y1;
}
cout << answer << "\n";
return 0;
}