-
Notifications
You must be signed in to change notification settings - Fork 1
/
1071.c
44 lines (41 loc) · 942 Bytes
/
1071.c
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
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
int main(){
int total,time,i,j;
scanf("%d%d",&total,&time);
for(i=0;i<time;i++){
int n1,n2,b,t,flag=1;
scanf("%d%d%d%d",&n1,&b,&t,&n2);
if(total<t){
printf("Not enough tokens. Total = %d.\n",total);
continue;
}
n2-=n1;
if(n2>0&&b==0){
t=-t;
flag=0;
}
if(n2<0&&b==1){
t=-t;
flag=0;
}
total+=t;
if(total==0){
printf("Lose %d. Total = 0.\n",total-t);
printf("Game Over.\n");
return 0;
}
else{
if(flag==1){
printf("Win %d! Total = %d.\n",t,total);
}
else{
printf("Lose %d. Total = %d.\n",-t,total);
}
}
}
return 0;
}