-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathY2K_accounting_bug.cpp
More file actions
57 lines (53 loc) · 1.33 KB
/
Y2K_accounting_bug.cpp
File metadata and controls
57 lines (53 loc) · 1.33 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
Made by: Romeu I. L. Pires
for "Special topics in programming" course
in UFRJ (Universidade Federal do Rio de Janeiro),
on 2019.1 semester
- Problem PDF:
https://uva.onlinejudge.org/external/105/p10576.pdf
*/
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
ifstream cin("entrada.txt");
ofstream cout("saida.txt");
#endif
// ==========
int s , d , i;
while( cin >> s >> d ){
int superplus_per_part = 0;
int max_income = 0;
for( i = 1 ; i <= 5 ; i++ ){
if( i*s - (5-i)*d > 0 ){
superplus_per_part = i-1;
break;
}
}
switch( superplus_per_part ){
case 0:
max_income = 0*s - 12*d;
break;
case 1:
max_income = 3*s - 9*d;
break;
case 2:
max_income = 6*s - 6*d;
break;
case 3:
max_income = 8*s - 4*d;
break;
case 4:
max_income = 10*s - 2*d;
break;
}
if( max_income > 0 )
cout << max_income << endl;
else
cout << "Deficit" << endl;
}
}