Общий форумV zadache Pahom i ovrag u mena WA 2 test. Wse moi testi prohodat. Pomogite razobratsa! To solve this problem we must use 64-bit variable. When i wrote in my code "printf("%lld\n",res)" i've got WA on test number 7. But when i wrote "cout<<res<<endl",i've got AC. My friend had the same problem. So what does it mean? Sorry, i must be more careful and write "printf("%I64d\n",res)". I have TLE on test 7. Why it can be? Me too~~~~~~ Requests with equal times should be processed as they appear in input !!! TLE 7 is probably like this 1+ 1+ 1+ 1+ 1+ 1+ ... ... ... ... Edited by author 15.08.2008 02:14 Thanks for your hint (about requests with equal times), i've got AC now :) Hello, I've WA5 can you give me some tests,please? I do not understand, how to solve with memory 200KB, I have a massiv [0..1800,0..9]of [0..10000], and of course my solve loses with memory and time. I do with standart dynamic, Help me, please! Thank to everybody, I have understood myself!!!! Edited by author 05.02.2010 22:09 Try to check your output in case, were coefficient's are negative. For example: 0*z^2-z^1 ans -z It's very important to check output of singums! 4 )(( ( )) ))((( 20 )(( ( )) ))((( )(( ( )) ))((( )(( ( )) ))((( )(( ( )) ))((( )(( ( )) ))((( 200 ())()))))((((((()()())())())(()()()((()(() ()((()())(((((())()))))))))()()))(()(())))))())()(()))((((()))()()(()))(((()))()((()()))()))((((((((((()()))))())()()()()((())())))()( )()(())))(()()((()(()()(()(())()))(()(((((()()))))))(()(()))))()()(() ()))())))((()))())(((())(()))((()(((()()())(())()(()())(()(()())(((()(((()(((())())())()()((((()))(()()))()))((()())()(()))(()())))(()()(())))))(()(()(()())( )(()(((()()((()(((())))))()()))((())(()))()(())))())(()))())()))()()(())())((()((()()))()(((())))))(((( ))))()()()())((())(()()()((()))()()()()))(()))()((((())()()((((((())(()))))(()(((((()()())(((((()))(())((()())()())()(((())(()))()()(()))())((())()(()(()( ))(()()(((())(()((((()()((((())()())()()))(()((()()(()))((())))(((())())()((()))()((()()()))(()))()((((()((()(()(((((())))()))))(()))()(()()( ))((())())((((())())(())))))(( ())(( ))()))))))((()(((()))))(())))()()()))((())))))(()()(()(())()))((()()((((())(()())()())((((((())()(((()())))())))((((())()())(()()(())))(()((((()()())(()))(()()(())))) ()))()()(()()(()(())))((())))()))()))())()()()))()(()())())))())))((())()))))())))(()()( ()())(()()))()(()() ))))()(((((()))()()()(()()(()()()()))((((()(())))(()())))))())((((((((())(())()()(((()))()))))()))(())))()))()((((())()())()))()()(()))()()))()()))((()()()())))()))())((()())()()()(()(()()()(((())()( )(((((())))()(()))()((((((()))))())()()())))))()((()(())))(()()(((())()))))())()(())))())))()())(((((()))(()(()))(())())(((())()()))((()(())()((((()()))))()((())))()(()()))((())(()))()()))()()) )())())()(()((())))()()(((())(()(())(())((())()))((())(())((((()))(())(())((((())))((()(()((())())()))(((((()(()))(()))()))(()((()(())()(((())())())()(()()())))((((()(((())(((()(()(())(()(())()(()()) )())())()()()(()))))())(()())(((())((())()()()()(((()()))())())((((()((((()((())((()()))(()))(()()())(((((()(())())((()()))()()()))())))))()))(()())( )()()()(())()()()))))()))((((()(((((()(((()(())))(())()(()())()()))((()((()())(()()((())(((((()(()(())))())(())((()(((((((()(())(((()())))(()))())(())()(()) ((())()(((()))()))(()()))()(())(((()()()(((()() ()))(())())((()))((()((((((()((())((((())))(()((()(()()(()((())))())())(()()())))(((((()(()((()()()))( (()(()(()(()()()(((()()))(((()()()(())()())()())))(()())( ))((((()())((())()()())()))()(()()(((())()((())())))()()())))())(((())))))(())(())(((()((())(())))(()())(()(()((())()(())(((()()()(((()((()((())((((((()()))()())())))(()(()()))))((()))((()( (()()(((()())()()(((((()()(((()()(( ())()())()()())(( ()()) )((()))()(()))))(()((((()))(())())())())()((()()(()(()(())(())))()(()()()()()()(()(((()(()(()())())())((()())())()()((()()()))())((())(()()((((()(()(((()(())((()())))(()))()()(())(()(((()))) (())))))()())()(()))))()))()))))(())())()))()))(()(())()))()()(((()()()((()))(()((()()()()() )(( (())((((()(())()()()()(())(()()((()()))())()(((()(()(()))))()(()()) )((()))(()(()(()))())())))()()))()(((((()))(())))()()))(()()()(((())(()((()(()()(((((()((())((())(((())((()((((())) ))()))(())))(((((()))())()()))))()(()((())(()(())))))((()(()()(((()(()((()() ())(((())()())()())))()()))(()((((()(()()()))()((())((()))))))()(((()(((())(((()()(())(())))))( ))))(()()))))((())(()))))(((()()(()())((()((()()())(()(())(((())))((((((())()(()))(()()))))()()(((()(((()(())()())))(()(())(()))((())()()())(())(((()()))(()((())()()) ()()()())((())))(()(()((()((()((()))(()(((((((( )))))))(()())())()(())(((()()((()(()(()))))()))))(()))(()(()(()((()(())))()(())()()(((()))(((()))()()())(()(()()()()(())()()(( ))())()((())()())(())((()(()(()))((())))((())())())))())(())()(((((())))(())())))))())()((()()))(((((()))(()((())(()((())((()(()())()()))((())((()())((((())(())))()()(((()))()))((((() (())))(())))))(()()))(())(()((()(())(())()())))()()(((()())(()()(()(()(())(()))()()))()((()(())(()))()(()))))())))()()))()()()))()()()( ))))()(())))()())))())(()))())))())()((()))()(()(((((()()(()())(()))())()(((((())))((((((())))(()(()(()()()(())((())(())))())))(((()())))))()))))(()(((((()()())(())())()(()()()()()())((()))))) )())()())()))))))())))(()))(())(())()((()())(((((((())((()((())((())()))((()))))()())()))))()))))(((((())(()()((()())(((()))))(((((())((()(()(())())))( )())(()((((((((()(())))()))))(()()()))())(()))(((()()()))()(())))()(()()((())()))) ()))))()))(()())(())))(()()(()))(()()))(((()(((()))((()(()(()((((((()))()())))())())))()(()())()()))())())(((()(())))() ()()))()))(()))))))))()(((()(((((()()(()(())(()(((((())))))(()))))(((((((())(((()((())(()(()(()(((()((((()())(()(()(()(((()()()())(()))(()((())()()((()))))()))(()))())) )))()()))))(((()(()))))(()())(())())()))()))())))()(())((((())(((()( )()))))(()))))(()))))()))())))()()((())()()(( ((()()(())())( ()(())))()())(((()))()())))()))((()((((()((())())))(((())))())))))(()())))(())()(())(()))()(((()()))(((()(()())()))))(())))()))(()()((())())())))))((())(()()((()))()))(()))())(())(())))(()) ())(()()))(()((())(((()())()((())()()(()()((()()))((( (()((()))))))(()((()()(()())))()())))()()(((()())()()( )(()))(()()((()()(()((()((()(((()))()(()(())))()))((( ))()()())(((((())))((())())))(()((()))()()(((((((((()(())())))(()((((((((((()()((()(()(()))()())()) ))))))((())())))))())()))))))))()()()())()))(()))(()()))(((())()))(())))((((())))(())((()(()))))))((((((()(())))()))))))((((((((()())))((()()()))()((((()(()((())))()( ()()()))(()))(()())(((()((())()((()))((()))))()))()()(()(((()())))((()()()))))(()((()())())(((()))))())()))(()((()()(()))()(()()))()((())))()))()()(()))(( )()))())))()((()((()((()()))(()(()))))((((()()))(((()))()(((((()((((())()))(()((()(()()()()())))((((()()))))())))))((((()())())))))()((((())(()()))()((( )()))))()(((())()()((((((()()())))()())())()(())(((((())()))()((())()()))(()((((((()())()()))((()()())))()((()((()(()(()())((((((((() ))))(()(()()())))))(((()(((()((()))(((()())((())(()((( ))(((()((()))(()))())((()()()((((())())(((())((()))))())()(((()()))(((()))( )))(())))())(()(())())())))(()(())()()(()()())))))())()))((()( ))((())()(()))(()(()))()()()((((()((()))))((((()(((()))()()))())()))(()))()()((()))()(((()(((())())()(())()))(()(())()))(((((((())((((((()(())))(( )()))())() )))))(())()(())()(()))(())(()(((((()(()(()) )( )(()(())()())))((())()(())(())(()()(()))))()(()()()()(((())(((((()())((())))((())))()))(()())))())()))))()))(()()()(((( ()())((()()()()(())()(((())(( )()())))(((())()(())())()))))((((((()))(())))()((()(()(()(())))))()()(())((()((()))()))()(())))))((((()(()())()))(())))()((()))(()()()())(((()(()()))()())(()(()()(()(((((()(()()((()(( )(())(() ((()((()))())(()))()(())()())())))())())(((()))))))(())((()())()))()))()()(()()()))()(())())()((()))))((()()())(())((((())(())())()()))))())))())()))))))))))((((()((())())())(()))((())((()(())(()()()) )(()((()())(((()()()))())(())(()(((((()(()()))())(((()((() )(()()))))()(())()(()))))(()()()()((()))((()(()(()(((()(((()((())(()(((((())()()(()((()(()(()())()())()((())(((())()(())))(()(()()((()(()())))((())())()(()()())()((()()(()(()(((())(((()))))))())(( (()((())()(((((())))))()()(()(((()(()((())((())(()))(()()()()))))(()())()))))(()(((())()))((())())()((()())()(((()()))())()(()((()()(((()((())(()())(()))(())()(()()()( (()(()())(()))))()()(((())))(()(((()(((((())()))(())())(((((()()(()((()((((((()(()())( )(())(((((()))()()(((()(()))()())()(())(()(()))())())(((())()))()()(((()((()))))((((()))) )(()())(())))(()(((()(((()(()())()()))))))((()))())())))(())()(((())()(((()))())))))))(()()())))()(()())())))(())()())(())))((()(())()()())(()))(((())(((()((((()()()())(()()))((()()))(()())(( ()))))))(((())())(((()(()()()(()())(((((()()())))(()()())())((()() ()())((()((()()((((((())(()((()())()())()(())(()))))())()()()))()())()()())))()())())())((()))(()(((()((()(((((((()))((()))))())()()()(()))()(((())((()())()))((()()((((()()(()(()()((()))())))() )()(()()(((())((())())()))()((((()(()(()))((()()()))()())()()))())(())))))(()((((((()()()))()(((()))())))())))))((())((()(())))(((()()(())))))(()(()()(())) )))())()(()(()))((()())((( (())))((()))))))(()())()()((())())((((()))(()()())((()())(())()()))))(())))))()))(((()()()(())))())(())))(())())()()(()((()((((((()))()))()())((()()(((() (((()())()((((())))(())()())(( (())())())((())(())(())(()()(()(())(()(())()(()))((()(()()())))((())()())())(())())))(((((()(()))((()()())(((()((())))((()()()())(()))))))((( ))())(()))))))))()())(())(()()(()()()())()((()((())(()))())(()(((((())()((())()()(((((( )(()(((())((())())))()(()()))()))()))((()(()))(()())((()(()())))()()(())())(()))))(((()))()(()()(((()((( )()((((()()))(()))(()()(()()((((()(())((())()))))))()(()))()()())((((()(()))((()))()))))))))(()(())))))))(((((()))()))))((((()() )(()))))((())))(((((()(((()(()())()))))))((()))())(((((())()())((())(((())))(())()((()()))())((()))(()(((()))())))((((()())()))()()())(()(())()()(()(())()((((())( )())()(()()))())()(())(()))))()())))(()))()))()())))))))))(())()(((((())))))(())()())()((((()(()((()(()()()))(((((())())(()())()((()(()((() (((())()()()))))))))(((((())()()))()(())()()(()))(())))))((()))( ()))(()()(()))() ((((())))((((())(()()()(((((())()) (()(((())((((()(()()))))()))(((()()())((( (()()(())(())((())))()(())()()))))()())((())()())()((()))))()))))((((()))))(((())((((((() ))(()()((())())((((()()))(()(()))((( )()()())))((())))))())()(()())())()(())))))((()())()()))))()()()(())(()(( (())(())())())())))(()()()(()()))))(((()))((()((())(()()(()())))())())))(()(()(()())()()()(()))()( ()))()))(((((()(())))((()()((()))(())()()(())((((()((())))()()())(())))(()((())(())()()()((())((((((((()(((()())()(((()((()( ())((((())())(((((() )((()(())))()(((()((()))))))(()(())())())(()))(())))))())(((()))))(()()(())()) (((()(((()()(((()))())()())(())(()))(()))))((()((()()(()))))()))(()()()(()())))()(((())(())))()))()))))((()()((((()((()()(()))(()))((((()(())) )(((()))())(()()(()()(()())(()()((((())(())(())(((()((())((()))()())((( ))((())()))))))()()()))))()())()()()()(())))()()))()))(()())((())((())())(()()))()()))(()())(((())((()((((((()()(())))()()))))(((((())()())())((((( ))(())(((()()()()((((((())))(()((()(((()))()))))(()(()((())))(()(()()()(())(())))(())(())))((((()(()))(()((()())))((())()))))() ())()) ))))()())()(()((()((()())()((((((((()))(()()())(()((()))()(())())(((())()))())((()()))(()())(()()()(()))(()(()())))()()())))()(()) ()()(()((()))))))(())))()())(()((()())))()()(()(()(()()))))))))()(()(((((((())))(()(())()()))((()(((()()(()(()))()))))()((()((( ()()()(()()))))()()))))(()))(()))(((()))())))(())(((())))(((()()(())(((()()((()(()((((((((())())))()()))((((()))())(()(((((()(())()((()))()(()(()()(()())((((()))((((()()))())()()((( )()(()())))(()()))()(())( )((()()((()))(()))()))()()((())((()())))((((())()()(()((((((() ))) (((()))((())()((((((()))))()()((()((())())))((()))))( )((((((((()))((()(()())))()()))()))(())(()()))(((()))))()())(()(()))(()))))())()))))))())()(()))()()))()()))(((()())))))(()(()))()()()()((( ()(()))()))())))())())))()( ))()))()()))(((()()))()((())(())(()(()()()(()))()))((())()(()()(())()(()())())((()))()))()(((())())))(()()(()()(()()(()))((( )))))))()())(()((()()(((((()((()))(()()((())()))()(()(()((()))()()((()((()(()))))()((())(()))()())())(())))()())()()))((()((())))(((()))(((()())(()()(()()) ((()(())(()((()(()(()(()))))(((()()))())()))))((()()))(())))((())((())((())((((()())))(()((())))(( ))))))()((())))))((()(((((())())()(()(((()))()()((((()(()()))))(()()()())(((()(()())((()))()((()(()))(((())(()((()))((())()((((())()( ))))((((()())()((())((()))())(((()))))(((()())((())))))()))()()))(()(()())))((())())(((((())()())()()))))())())())))))()))(())()()(()()))(()()()))((())((()((()()(((((()))((())()(((((()()(())(((( ))))(())())((()(()())()(()()()))())))()()))(((()))(( ((()())(()()()(()))())()))))((()(()))(())()(())))))())(())()(((()(())())()))))())())((())((()())(()(())))()()(()))((())()()())(()()()))())()) )((()()()((((()())))(()(((())))((() )))))()())))()()())()(()))()()())(()(((()))())()()(()))))((())(()()())))(()()())))()(())(((()(((())()(((()))()))(((())()))())())(((())))()))((((((())(()(())))(((()(())())))))(()((()())( ))()))()((())()())))(()(((((()(()))()(()))()))(())))((()())()))()( )()()((((()))(()))()(()))))(((())(()())((((((()((()()())())((()())())(()())(())))))))()))))(()()))()(()())(())()(((((((()))(())))()(()())())((()(()())(() ()(()((()((((()()((()(((()))))))))((()))()(((()()())))(()((((((())()()(())))()(()()( ))))))()()(())(()()(())(()))()))(()))))()()((()((())))))(((())()))())()(())()(( ))))))()(()())))((() )(())()()))))(()((()(()()(()())))))))((((()(())))()((())() )()))(()(()))))())((((((()())((())())))())(()(()()())(())((((()))))))((()())))))))())(()())(()(()(((( ))())()))())(())()))))((((((())(((())))((()()())()((()()))()() ())())()()))()(((()()())(()()(())((())((()))(()()()())(()())(((())))()(())(()()))))(()(((()(()())))())(()((()(((()(()()())(()())(((((((()((()((()())(() ())())()(((()())) )()))()(()(()())))()))())))()(()((((()()))(())()()(((()))((((()))()) ))))((())((()(()))))(())(())((()()(())((((()())())(()))()()()()))()()(((()())))()(()((()(()(((((()(())((())())(()( (())))))()())()((()(()()()(()()()()(())(())()(()(())()))(((((((()))())((((((()(()()))())))(()((((((((()((())((()(((())(())()(((((((()))()(())))))()()()((()()))((())))()()((()((()())()())())()((()(())) )(()()))()))(()())()(()))(()))(()))()((())(())))))()())))((((()))()(()((()((()()()()())(((()()))))()(()(()))(()(()(()(()))))))(((()(())()(((( ((())())(()()((()(((((((((())(()(((())()))()(((((()()())()())()()())())(()))(()()))((()(()(())((()))()))( (()())())))()))()((((()))))(())(())()()()((()())(()(()((())((((())())(()())(())(()(()(()))()(())((()())(())()))))(()(()()())((()()))()()(((())))()))()((()())))(((()))))))))))))))((())))(()) ())())(()(() ((())())(()))((()(()()(((((((((()()))())()(()(((()))))()()((()))(((()()((((())(()))((()(()))(()((((()(()((()))))(())()((()))()())()((()()( ))((()(())))(()))))))))())))(()))())))((()))()((((()()(()()())()))())((((((()))(())())()())((())(())(()))()))()((())()(())())()(()))()())())(()(())()((() ))()))((())( )))((( ))()(((())(()())(((()()((((())))(((((()((()()(())((())())(()))))()((((((()((()())()())()()(()(((()(()()(())(()())()((((()((((())(()(()))))()()(((()(((())(()))(())))()()())((()()())()())(()))))())) (((((()())(((()))()()())(()()(()())(()()((((((((((())))(()(()()(())((()()(((()))(())()(()((())(((()))(()))))())()())))(())()))())()(()(()()((( ))()()())())()()((()()(((()()()(()(((((((())()))((()(( ()())(()((()(()))())(((()()))))((()) (((())))())()((())()))(((())())))))(((()((((((()()))(()())))(())(((()(())))))()(((((((())))()()((())())(()())( ((()())))))()()))()((())()(() ())(())()()((((()))))))(()))()())))))(()(((((())())())(()))(((()((((()((()))(()()())(()((()))))))()()()((())(()))())()))))(((((()()((()()))()))()))(()())((((()()(()))((()()())())())( ))))())(()(((()(()()()))()()((((()()))())(()))())())()))((()())()()( )()()(()(())(((((((())((()))))))()()())())))((())()))()(()()())) (((()( ()()))(())()()()(((())()((()((((())))(((()))())))()()((()()(()((()((()(()()())))) )()((()))((((())()(( ())()))())(()()()))()))(()))())))()()() () (())()())((()))))))())((()(()))()((()(()()(()))))))()(()(())())()()))))))())(()))((())(((()(()())))((((())()())))))(()())()())()(()()(()((()(((())()((((((())())(()()) )(())))((()()(()))())(((())((()))((())()))((((()(()(()(((( )(()))()))((()(((((()()()()()))((()(()))))()(()(()))()()))))()(((((()())()(()((()))()((())((((()())))((())()()()()(((((((()))))(((((())))(())())))(())()()))())())()))()(()))()))(()()(()()((())() ))()())(()))()))()))())())))()(()(()))))))((()()((()((((()((((()())(()(()()((()()((()())())((()()(((()(())()()((((()()((((())()()()())))))) )()())((())))))(())))(()(())(( ))())()())()(((()())()())())( ((()(())(()()(())(()(()()(((()))())((((()()))())()((()()()))(()))))))((()()())((((( )(())(()())()()))(())()()))()(()))))) ) ((()))))((()(()((((())(((()()((()))(())(((((())(( ()))()())))(()()((())(()))))(()))())())))(())())))((((()()())))))((()(())(()))))())())(())((())))))(()()()(()()(())((())(())))))))(()((((( (())()((()((()(())))())((((((() (()))(()((())()((()()()(())))())))(()())()))()())())))( ()())()))())((()())))()))()()())()((())())()(()(()))))))((())))(()(())())())(()(()(()()()(()(())())(()(()())((()()))))()()(())))))) ()(()))))((()(((())))(((((())()(()(()))((( ()())()(())))()())())(()()))))())))()))(((()()())())((((())(((()((()))))())(())()((()()(((((()(((())(((()(()))(())())((()( ((()))))()(())((())())()))))()())((((( ()(())))((((()(()))(()()((()((((())(()()())(()))))))(()))()()())()))))(((((((()())()(()(()))))(((()((((()))()(())))(()()((())())()))(()()()()()()()(()()))(()))())(()())())(((()(())(((())(( ))))())(()))()((((())))((())((((()(()(())()(())((()())))( (())())())(((((())((()((())()((()()()((())())(()))(())))(())()))())((((((()())(()))))())))(()()()(())(())()(()(()())(())()((((()()())))())()())())()((((()(()))( ((())()())()()(()(())(()))(()))))((())((((())))())()))())()))()()())))()())())((((()()))((()((((()(())()(()()())))))(()()()))(()(( ((()))(((()))())()))())))((()()()()))(()()((())))((((())()))()(()))))))())())()) ((((())((()()()(()(((()(()()()())))()))))(((())()(((())) (((())())(())()(()))())()))(((())()()()))(((()())()()()((())()(()(((((()(((()))(()))((()(()())(()))())))((((((())())(((((()(((()((()(()())())(())()((( ))()(())))()((((((())))())()(()((((()())())(())(()))(()(((()((((((((())())))()()())())((()((())()(())))( ))()(()()((()((()( )))(((()())) ((((((()()))))(()(())))))(())()))()(((()))))())()))(()(()())())()((((((()((())))(()))()()()(()))))(())())()()())()(()())) ((((()()(((()))(((())(((())(()(()()()))))())()(()() (((())()())(()))()(()) )))((()))(()(((()))()))()))(()())())())))))(()(()))()(()())((()()()()((()())))()((())))(()())((((()())))()()(()(((()(((()))()()()(())(())) (())()(())()() )((()(()()()))((())((()(()))())((()())))))))))))(()) )((()((((()))))())())(()()((())()(())(((())(()))()()()()()))((()))()(()(((()))))(()))())))((())())((())())()))))))))))))(())(((()(()()(()))())(((((()(()(()())()(())((())))(()()))()()(()(( )())))(())((())))))())(()(()()))))))())(((())()())))))() )(())()(()())))())())(())(())()()()))(())(()(()(()))))))))() (())(((()))(()()())()(((()())())(()((())))))(()()((()((())()(()(()(((()()(()()()(()()((()))) (((((()(()))()))())))))((()()(((()()(((((()()(()()))()((((()(()))(()))(((()((((()))()()()))(()(((((()()))()()))())()())))()() ()()))()())(((()(()))(()()()()()((()(())(((()((((()(())))()())))(()(())))())(((((((((()))((()((())((((((())(((((()((())(()()()())(((((()()((()()()))()(()))()(())(((())))(((())((((()()))())((( ()())(()()(())))(()((()(())(( ((()((()))(((())()()(()()((())(())()()))(())())(()()()((()())(())()()())()))() ((((())(()))((()((()((()))))())()))()))(())()((((())()())()(((((()))()())()(()()(())((((()())((()()()()))(())())(()(()()(())(()))()((())()()(()))(()())((()())((((())))()())()())(((()))())()( ())))()(((((())))(()((()))()((())(()))((())(((( (()((()())) )) )))()(((((())(((())()(())((()))()(((()))())()))()))()())))(()))()()))())()()))))()()(()(((())(())))(()(()))())))))()(( )))()((())((((((((())(()())())(((())))((((()))))(((())(()((())())))((((()((())())((())(((())))()()))(()))((()))))())))(())((((((()(()(()((())(((((())))()((((())(()))))))())) )()()((((())((((()()( Edited by author 04.02.2010 11:20 6 3 2 1 3 48 15 18 5 9 13 17 4 8 12 16 20 3 7 11 15 19 18272 184 120 152 106 196 193 184 175 28 182 181 159 189 132 68 140 20 77 9 96 194 60 18 116 135 70 64 142 62 172 57 55 46 139 48 134 104 98 7 192 111 149 89 176 78 19 49 154 138 15 167 190 191 195 199 75 126 92 170 155 25 177 129 73 82 1 100 130 143 31 53 21 72 6 171 4 59 52 54 17 67 95 29 80 110 32 63 30 112 35 102 41 79 168 156 113 83 97 38 50 101 131 153 71 76 186 10 88 34 42 16 173 124 125 163 13 26 109 117 145 169 128 119 65 61 183 5 2 81 123 157 56 43 47 37 90 107 136 114 121 122 3 40 8 11 51 91 146 137 144 198 23 36 108 12 165 118 74 84 179 127 103 158 161 14 166 151 39 147 185 160 187 188 45 58 133 85 174 99 115 24 197 94 105 180 My program writes 0.8561 and gets WA Help... I`ve found stupid mistake and got AC! Doski ne mogut bit raspologeni gorizontalno! Thanks, i had this mistake too :) It was WA #3 I got AC with O(n) ! Several times I got TL, but when I stopped reading the input with java.util.Scanner and started using java.io.BufferedReader it worked. java.util.Scanner is too slow, don't use it ! thnx, otherwise TL21 class Scanner { StreamTokenizer in; Scanner(InputStream stream) { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(stream))); } void asserT(boolean e) { if (!e) { throw new Error(); } } int nextInt() { try { in.nextToken(); asserT(in.ttype == in.TT_NUMBER); asserT((int) in.nval == in.nval); return (int) in.nval; } catch (IOException e) { throw new Error(e); } } } ".. and nothing else matters ..." (c)Metallica #include <iostream.h> bool z(int); void main() {int n,i,q=1; cin>>n; for(i=1;i<=n;i++) q*=2; for(i=0;i<10000;i++) if((z(i)) && (i%q==0)) {cout<<i; break;} if(i==10000) cout<<"No solution";} bool z(int x) {int j=0; while(x!=0) {if((x%10!=1) && (x%10!=2)) j++; x=x/10;} if(j==0) return true; else return false;} Imagine that n is 100. q (2 ^ 100) will be overflowed. You must have 10000 digits but not number under 10000=) Here is mu code(C++): #include <iostream.h> void sdvig(char a[],int n) { char *y; y=new char [n]; int i,j,total=0; for(i=0,j=1;i<n,j<=n;i++,j++) { if(j==n) { y[0]=a[n-1]; } else { y[j]=a[i]; } } for(i=0;i<n;i++) { a[i]=y[i]; } } bool proverka(char x[],char y[],int n) { int total=0,i; for(i=0;i<n;i++) { if(x[i]==y[i]) { total++; } } if(total==n) return true; return false; } const int N=250000; int main() { char x[N],y[N]; int n,i,total=0; cin>>n; for(i=0;i<n;i++) { cin>>x[i]; } for(i=0;i<n;i++) { cin>>y[i]; } if(proverka(x,y,n)==true) { cout<<"0"<<endl; } else { while(true) { total++; sdvig(x,n); if(proverka(x,y,n)==true) { cout<<total; break; } else { if(total==n) { cout<<"-1"<<endl; break; } } } } return 0; } When sum<=T (which means that the limit is not exceeded ) you should write just a monthly fee N2. In C++ : if (sum<=T) cout<<"Combined: "<<N2<<endl; Good Luck Friends!!! I got WA at test 10... I compared my source with an AC one and got same results on many tests... oh God I've wrote if (H == 13) H = M = S = 0 and got AC ! In test 10 you may have a precision problem. When comparing double values use some epsilon like 1e-9. It worked for me at least... I rewrote everything to long arithmetics and fair fractions, still WA10. The problem is that the answer is 00:00:00. I checked only control points (moments of power and weakness for all 4 forces), but if resulting function is minimal and constant on range [x2;24*60*60) U [0;x1), then the answer should be 0. Simply adding 0 to list of points to check gave me AC. I believe solution with 'double' type would also do it :) Edited by author 11.08.2008 08:58 Oh, thank you very much! I added zero to my check list and at last i have AC now too :) (I had WA #10 before it) Well, everybody here knows, that best scheme is 0(X*i+) . But lot of us get WA1. I've found why we fail like this. The last line of output shouldn't contain line break, so I've changed string "X\n*\ni\n+\n" to "\nX\n*\ni\n+" and got AC. OMG. It is very strange :) for (int i = 1; i <=n; i++ ){ out.printf("X%n*%n%d%n+%n",i); } (Java) any hint? while i have more than two vectors, i find two of them with |sum|<=L. in the end i have two of them and try to sum in different ways, but wa5 This code dont worked! Why? I dont know what i should to change. type TPoint = record X, Y: Extended; end; var N, R: integer; Points: array of TPoint; Sum: Extended; function GetR(Index: integer): Extended; begin Result := sqrt( sqr(Points[Index].X - Points[Index + 1].X) + sqr(Points[Index].Y - Points[Index + 1].Y)); end; var i: integer; begin Readln(N, R); SetLength(Points, N + 1); for i := 0 to N - 1 do with Points[i] do Readln(X, Y); Points[N] := Points[0]; // зацикл Sum := 2*pi*R; for i := 0 to N - 1 do Sum := Sum + GetR(i); Writeln(Sum:0:2); end. Thanks; I think that following formula correct: Sum := 2*pi*R + R(1, 2) + R(2, 3) + ... + R(N - 1, N) + R(N, 0) ; Where R(i, j) - is function which returns distance between i and j nail's. Where i'm wrong? Edited by author 21.08.2008 13:57 Edited by author 21.08.2008 13:57 Anybody, give me please same test's OOOOOOoo :). My solution is correct. :0 My bug was here .... R: integer; .... but should be float type. unattentive thanks, my error was the same :) me too :D thank you! //81674XO #include <iostream> #include <cmath> using namespace std; int main(){ double PI=acos(-1.0); int N; double r, perimeter; cin>>N>>r; double *pointx, *pointy; pointx = new double[N+1]; pointy = new double[N+1]; for(int a=0; a<N; a++){ cin>>pointx[a]>>pointy[a]; } pointy[N]= pointx[0]; pointx[N] = pointy[0]; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); if(N==1){ perimeter=2*PI*r; cout<<perimeter;
} else{ if(N==2){ perimeter=2*(pow((pow((pointx[0]-pointx[1]),2)+pow((pointy[0]-pointy[1]),2)),0.5)) + 2*PI*r; cout<<perimeter;
} else{ double angle; for(int a=0; a<N; a++){ perimeter += pow((pow((pointx[a]-pointx[a+1]),2)+pow((pointy[a]-pointy[a+1]),2)),0.5); }
double p1x, p2x, p3x, p1y, p2y, p3y, m1, m2;
p1x=pointx[N-1]; p2x=pointx[0]; p3x=pointx[1]; p1y=pointy[N-1]; p2y=pointy[0]; p3y=pointy[1]; if(p3x==p2x) m1=tan(PI/2.0); if(p2x==p1x) m2=tan(PI/2.0); if(p2x!=p3x) m1=(p3y-p2y)/(p3x-p2x); if(p2x!=p1x) m2=(p1y-p2y)/(p1x-p2x); angle = 2*PI - (PI + fabs(atan(m1)-atan(m2))); for(int a=1; a<N; a++){ p1x=pointx[a-1]; p2x=pointx[a]; p3x=pointx[a+1]; p1y=pointy[a-1]; p2y=pointy[a]; p3y=pointy[a+1]; if(p3x==p2x) m1=tan(PI/2.0); if(p2x==p1x) m2=tan(PI/2.0); if(p2x!=p3x) m1=(p3y-p2y)/(p3x-p2x); if(p2x!=p1x) m2=(p1y-p2y)/(p1x-p2x);
angle += 2*PI - (PI + fabs(atan(m1)-atan(m2))); }
perimeter += r*angle; cout<<perimeter; }} return 0;}
// please run my program and also, for some test cases and check for difference in answers !! pizdos u teb9 proga)) 9 dumau 4to delo nemnogo v kode) program project1; var n, i : shortint; r, res, x, y, x1, y1, x0, y0 : extended; begin readln(n, r); readln(x, y); x0:=x; y0:=y; res:=2*pi*r; for i:=1 to n-1 do begin readln(x1, y1); res:=res+sqrt(sqr(x1-x)+sqr(y1-y)); y:=y1; x:=x1; end; write((res+sqrt(sqr(x1-x0)+sqr(y1-y0))):1:2); end. Why WA 8? Please help me ! I tested my programm many times, but did'not find a mistake. Maybe someone tell me where is wrong or give me same test. Sorry for my bad english. Here is my code: program Project2; {$APPTYPE CONSOLE} uses windows; type din=array of longint; type IntMas=array[1..2000] of longint; var mas,mas2:din; pre,rez:intMas; n,i,dlin,dlin2,kol,u,y,save,KOLM,a,b,sr,MAX,num,del,l,r:longint; f:text; // lMas:array[1..2000,1..2000] of longint; DELTA:array[0..1000000000] of boolean; T:BOOLEAN; t1,t2,t3,t4:_SYSTEMTIME; procedure sort(var d,d2:din;var l:longint); var dlin,dlin2:longint; mas2,mas3,Dmas2,Dmas3:din; begin t:=false; dlin:=l div 2; dlin2:=l-dlin; setlength(mas2,dlin+1); setlength(Dmas2,dlin+1); for i:=1 to dlin do mas2[i]:=d[i]; for i:=1 to dlin do Dmas2[i]:=d2[i]; setlength(mas3,dlin2+1); setlength(Dmas3,dlin2+1); for i:=1 to dlin2 do mas3[i]:=d[i+dlin]; for i:=1 to dlin2 do Dmas3[i]:=d2[i+dlin]; if dlin>1 then begin sort(mas2,Dmas2,dlin); end; if dlin2>1 then begin sort(mas3,Dmas3,dlin2); end; kol:=0; i:=1; u:=1; L:=dlin+dlin2; while kol<l do begin if mas2[i]<mas3[u] then begin inc(kol); d[kol]:=mas2[i]; d2[kol]:=Dmas2[i]; if i+1<=dlin then inc(i) else begin for y:=u to dlin2 do begin d[kol+y-u+1]:=mas3[y]; d2[kol+y-u+1]:=Dmas3[y]; end; break; end; end else begin inc(kol); d[kol]:=mas3[u]; d2[kol]:=Dmas3[u]; if u+1<=dlin2 then inc(u) else begin for y:=i to dlin do begin d[kol+y-i+1]:=mas2[y]; d2[kol+y-i+1]:=Dmas2[y]; end; break; end; end end; //sort() end; begin {assign(f,'input.txt'); reset(f);} readln({f,}n); setlength(mas,n+1); setlength(mas2,n+1); for i:=1 to n do begin read({f,}mas[i]); mas2[i]:=i; end; t:=false; if n>1 then sort(mas,mas2,n); rez[1]:=1; kolM:=1; DELTA[0]:=true; for i:=1 to n do for u:=i+1 to n do if not DELTA[mas[u]-mas[i]] then begin del:=mas[u]-mas[i]; DELTA[del]:=true; num:=mas[u]; num:=num+del; kol:=2; pre[1]:=mas2[u]; pre[2]:=mas2[i]; l:=u; r:=n; while true do begin if mas[l]=num then begin inc(kol); pre[kol]:=mas2[l]; num:=num+del; l:=l; r:=n; // break; end; if mas[r]=num then begin inc(kol); pre[kol]:=mas2[r]; num:=num+del; l:=r; r:=n; // break; end; if (mas[r]<>num) and(mas[l]<>num) then begin if ((abs(r-l)=1) or (abs(r-l)=0)) then begin if kol>kolM then begin for l:=1 to kol do rez[l]:=pre[l]; kolm:=kol; end; break; end; if mas[(l+r)div 2]<num then l:=(l+r)div 2 else r:=(l+r)div 2; end; end; end; writeln(kolM); for i:=1 to kolM do begin write(rez[i]); write(' '); end; //readln;
end. 9 1 3 5 11 2 3 4 7 9 answer: 6 1 2 3 8 9 4 People, __int64 not needed! I quickened my program from 0.31 to 0.15 when returned __int64 to int (if that was not a fluctuation). Listen here. During one meal Ivan can save about 2*10^6/3 ~ 666667 rub. This is maximum increment of saved money. So at maximum the saved sum will be 2*10^9 + 666667, which is much less than 2^31-1. My trouble (and most likely yours too) was connected with that i checked if saved sum is strictly greater than n fogetting of the fractional part. This is the case when ( integer part of saved money == n) BUT ( integer part == n AND fractional part > 0) |
|