Moved kattis from Uni repo
This commit is contained in:
2
kattis/problems/27_10_23/monopoly/1.in
Normal file
2
kattis/problems/27_10_23/monopoly/1.in
Normal file
@ -0,0 +1,2 @@
|
||||
1
|
||||
7
|
2
kattis/problems/27_10_23/monopoly/2.in
Normal file
2
kattis/problems/27_10_23/monopoly/2.in
Normal file
@ -0,0 +1,2 @@
|
||||
2
|
||||
2 12
|
2
kattis/problems/27_10_23/monopoly/3.in
Normal file
2
kattis/problems/27_10_23/monopoly/3.in
Normal file
@ -0,0 +1,2 @@
|
||||
11
|
||||
2 3 4 5 6 7 8 9 10 11 12
|
35
kattis/problems/27_10_23/monopoly/main.c
Normal file
35
kattis/problems/27_10_23/monopoly/main.c
Normal file
@ -0,0 +1,35 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define MAX 12
|
||||
|
||||
int rollProbability(int number) {
|
||||
int sum = 0;
|
||||
for (int i=1; i<=6; i++) {
|
||||
for (int j=1; j<=6; j++) {
|
||||
if (i+j == number) {
|
||||
sum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int hotels;
|
||||
int distances[MAX];
|
||||
|
||||
scanf("%d", &hotels);
|
||||
|
||||
float sum = 1/6;
|
||||
for (int i=0; i<hotels; i++) {
|
||||
scanf("%d", &distances[i]);
|
||||
}
|
||||
|
||||
for (int i=0; i<hotels; i++) {
|
||||
sum += rollProbability(distances[i]) / 36.0;
|
||||
}
|
||||
|
||||
printf("%f\n", sum);
|
||||
return 0;
|
||||
}
|
24
kattis/problems/27_10_23/monopoly/main.c.orig
Normal file
24
kattis/problems/27_10_23/monopoly/main.c.orig
Normal file
@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define MAX 12
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int hotels;
|
||||
int distances[MAX];
|
||||
|
||||
scanf("%d", &hotels);
|
||||
|
||||
float sum = 0;
|
||||
for (int i=0; i<hotels; i++) {
|
||||
scanf("%d", &distances[i]);
|
||||
}
|
||||
|
||||
for (int i=0; i<hotels; i++) {
|
||||
sum += distances[i]/6.0;
|
||||
}
|
||||
|
||||
|
||||
printf("%f\n", sum);
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/27_10_23/monopoly/program
Executable file
BIN
kattis/problems/27_10_23/monopoly/program
Executable file
Binary file not shown.
Reference in New Issue
Block a user