1599: [usaco 162 Oct] bulky stone time limit: 10 sec memory limit: MB
Submit: 758 solved: 513
[Submit] [Status] Description
Bessie liked board games and role-playing games, so she persuaded Farmer John to take her to a toy store where she bought three different dice, which were of even quality, there are S1, S2, and S3. (2 <= S1 <= 20; 2 <= S2 <= 20; 2 <= S3 <= 40 ). I want to know the sum of the highest probability of occurrence. The question shows the number of faces of Three dice, so that you can find the sum of the most likely faces. If there are many types that are the same as the probability of appearance, a smaller one will be output.
Input
* Row 1: Three integers separated by spaces: S1, S2, and S3
Output
* Line 1: The required Solution
Sample input3 2 3
Sample output5
Output details:
This is all possible.
1 1 1-> 3 1 1-> 4 2 1-> 4 2 2 1-> 5 3 1-> 5 3 2 1-> 6
1 1 2-> 4 1 2-> 5 2 1 2-> 5 2 2 2-> 6 3 1 2-> 6 3 2 2-> 7
1 1 3-> 5 1 2 3-> 6 2 1 3-> 6 2 2 3-> 7 3 1 3-> 7 3 2 3-> 8
5 and 6 are the most likely to appear, so the output is 5.
Hint Source
Qualifying Round
Question: I just started to output (x + y + Z + 3)> 1. As a result, after wa, I started to launch a brute force attack and thought about it, as a result, I had a small program, and I was scared by a pair of beats... Almost all of them are different... Code: 1. Error
1 var x,y,z,i,n:longint; 2 begin 3 assign(input,‘input.txt‘);assign(output,‘output2.txt‘); 4 reset(input);rewrite(output); 5 readln(n); 6 for i:=1 to n do 7 begin 8 readln(x,y,z); 9 writeln((x+y+z+3)>>1);10 end;11 close(input);close(output);12 end.13
View code
2. Positive solution = violence
1 var x,y,z:longint; 2 i,j,k,l,n,max,ans:longint; 3 f:array[0..100] of longint; 4 begin 5 assign(input,‘input.txt‘);assign(output,‘output.txt‘); 6 reset(input);rewrite(output); 7 readln(n); 8 for l:=1 to n do 9 begin10 readln(x,y,z);11 fillchar(f,sizeof(f),0);12 for i:=1 to x do13 for j:=1 to y do14 for k:=1 to z do15 inc(f[i+j+k]);16 for i:=1 to x+y+z do if f[i]>max then begin max:=f[i];ans:=i;end;17 writeln(ans);18 end;19 close(input);close(output);20 end.
View code
Why? Please kindly advise.