UVa 11608 - No Problem

Contents

  1. 1. Problem
  2. 2. Solution
  3. 3. Code

Problem

中文網址

Solution

檢查題目數量 -> 足夠則使用題目,並減少題庫數 -> 存入新的題庫。

Code

UVa 11608
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
#include<cstdio>
#define N 12
int main()
{
int Case = 1,sum;
int p[N], need[N];
bool ans[N];
while (scanf("%d", &sum) && sum >= 0)
{
int i;
for (i = 0; i < 12; i++)
scanf("%d", &p[i]);
for (i = 0; i < 12; i++)
scanf("%d", &need[i]);

for (i = 0; i < 12; i++)
{
if (sum >= need[i])
{
sum -= need[i];
ans[i] = true;
}
else
ans[i] = false;

sum += p[i];
}

printf("Case %d:\n", Case++);
for (i = 0; i < 12; i++)
puts(ans[i] ? "No problem! :D" : "No problem. :(");
}

return 0;
}