# GYM

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 This problem has been solved by kerry.

 Sorter: kerry Unknown http://acm.pku.edu.cn/JudgeOnline/problem?id=2321

GYM is problem number 2321 on the Peking University ACM site.

Kerry's correct C answer. The old one looks so embaressing now!

```#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {

int input[12][12], basket_count[12], line_count, i, j;
long double prob[12][12];
for(i=0;i<12;i++) {
for(j=0;j<12;j++) {
input[i][j]=0;
prob[i][j]=0.0;
}
}
line_count=0;
get_prob(input, basket_count, line_count, prob);
}

int get_input(int input[12][12], int basket_total[12], int *line_count){
char a;
int i,j;
a='a';
i=j=0;
while(1) {
while(a!='\n') {
if(a==EOF)
return;
scanf("%d", &input[i][j]);
a=getchar();
j++;
}
*line_count+=1;
i++;
j=0;
a='a';
}
}

int get_prob(int input[12][12], int basket_total[12], int line_count, long double prob[12][12]) {
int i, j;

for(i=0;i<line_count;i++) {
for(j=0;j<12;j++) {
}
}
}

int calc_answer(long double prob[12][12], int line_count) {
int i, j, k;

for(i=0;i<12;i++)
for(j=0;j<12;j++)

for(i=1;i<10;i++) {
for(j=0;j<line_count;j++) {
for(k=0;k<line_count;k++) {
}
if(j==(line_count-1))
else
}
printf("\n");
}
for(j=0;j<line_count;j++) {
if(j==(line_count-1))
else
}
}

```

Here's what I've got. PKU says Wrong Answer, but I can't figure out why. My input and out are below the code.

```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {

char *a, **b, *input[10];
int n, i, j, k, baskets[10][10]={0}, total[10]={0};
double prob[10][10]={0.0};

for (i=0;i<10;i++)
input[i]=(char *)malloc(sizeof(char)*31);
n=0;
while (fgets(input[n++], 31,stdin)) {
}

n--;

for (i=0;i<(n);i++) {
a=input[i];
for (j=0;j<(n);j++) {
a=*b;
}
}
for(j=0;j<n;j++) {
for(i=0;i<n;i++) {
if (total[i]!= 0)
prob[i][j] = (double) baskets[i][j]/total[i];

}
}
printf("\n");
for (k=0;k<9;k++) {
for(i=0;i<n;i++) {
for(j=0;j<n;j++) {

}
}
for(i=0;i<n;i++) {
}
printf("\n");
}
}

Input:
1 5 7 10 2 6 2 1 2 0
1 0 1 2 9 1 10 5 9 0
1 0 0 0 1 1 1 1 1 1
1 1 1 1 9 3 2 4 5 4
1 5 7 10 2 6 2 1 2 0
1 0 1 2 9 1 10 9 9 0
1 0 0 0 1 1 1 1 1 1
1 1 1 1 3 3 2 3 9 3
1 0 0 0 1 1 1 1 1 1
1 1 1 1 9 3 1 4 5 4

Output:
1.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000
0.02778 0.13889 0.19444 0.27778 0.05556 0.16667 0.05556 0.02778 0.05556 0.00000
0.06358 0.02156 0.03382 0.04838 0.20062 0.09513 0.14449 0.13888 0.17095 0.08258
0.06952 0.04615 0.06366 0.08851 0.14432 0.12513 0.10906 0.11314 0.15793 0.08258
0.06717 0.03950 0.05557 0.07759 0.15990 0.11646 0.11790 0.12106 0.16261 0.08224
0.06786 0.04127 0.05769 0.08043 0.15559 0.11885 0.11546 0.11890 0.16151 0.08244
0.06768 0.04078 0.05711 0.07965 0.15676 0.11820 0.11613 0.11950 0.16181 0.08239
0.06773 0.04091 0.05727 0.07986 0.15644 0.11838 0.11594 0.11933 0.16173 0.08240
0.06771 0.04088 0.05723 0.07980 0.15653 0.11833 0.11599 0.11938 0.16175 0.08240
0.06772 0.04089 0.05724 0.07982 0.15650 0.11835 0.11598 0.11937 0.16175 0.08240

Input:
2 1 2 0
1 0 1 2
1 0 0 0
1 1 1 1

Output:
1.00000 0.00000 0.00000 0.00000
0.40000 0.20000 0.40000 0.00000
0.61000 0.08000 0.21000 0.10000
0.49900 0.14700 0.28900 0.06500
0.54160 0.11605 0.25260 0.08975
0.52069 0.13076 0.26809 0.08046
0.52917 0.12425 0.26108 0.08549
0.52519 0.12721 0.26411 0.08350
0.52686 0.12591 0.26275 0.08448
0.52609 0.12649 0.26334 0.08408

```