you are welcome!
you had ever helped me on some nasty problems.
I am testing and optimizing my ac codes for the problems I solved,found the precision is the main trouble in the new system.
no one can get ac on P216 now,it is an easy backtracking problem.
I think it must be a classical sample.
10751 - Chessboard
Moderator: Board moderators
Re: 10751 - Chessboard
notice 2 things
1. print "4" digit after demical point
2. "blank line" : print blank line "between" every output case.
sample output code
1. print "4" digit after demical point
2. "blank line" : print blank line "between" every output case.
sample output code
Code: Select all
for(int i=0;i<times;++i){
//calculate the path length
printf ("%.4f\n", path_length);
if( i != times-1) printf("\n"); //dont print \n after the last case
}
Re: 10751 - Chessboard
I checked it for small n, then I found a pattern, but I have no proof for it.
Input :
Output :
Input :
Code: Select all
10
1
2
3
4
5
6
7
8
9
10
Code: Select all
0.000
4.000
9.414
17.657
28.728
42.627
59.355
78.912
101.296
126.510
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10751 - Chessboard
Your I/O is correct. Printing 3 digits after the decimal point is enough, printing 4 is also fine.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 16
- Joined: Thu Oct 10, 2013 8:06 am
Re: 10751 - Chessboard
Code: Select all
Code removed after AC
Last edited by sadmansobhan on Tue Nov 05, 2013 8:32 pm, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10751 - Chessboard
Print a blank line between test cases. Don't print an extra blank line at the end.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 16
- Joined: Thu Oct 10, 2013 8:06 am
Re: 10751 - Chessboard
@brianfry713 thanks for your precious hints. I had one other severe fault and for that my code missed some digits after decimal point. My fault was to taking datatype - but the correct approach is to print the answer as. Thanks again ![:wink:](./images/smilies/icon_wink.gif)
Code: Select all
float
Code: Select all
double
![:wink:](./images/smilies/icon_wink.gif)