|
|
Common BoardGive me tests... 24 5 11 6 3 2 1 48 6 23 12 6 3 2 1 correct? My AC Solution: 24 5 12 6 3 1 1 ---- 48 6 24 12 6 3 1 1 ---- 1024 10 512 256 128 64 32 16 8 4 2 1 Good luck. Edited by author 30.03.2009 22:54 I`m interesed too, is it correct answer for this example: ***input*** 12 ***output*** 4 6 3 1 1 as in exanple answer is a little different, it is 4 5 3 2 1 I have got wrong answer on first test!! my program out right test on my computer! I've solved this problem in Java! http://acm.timus.ru/status.aspx?space=1&num=1220&author=23793 FAQ ( http://acm.timus.ru/help.aspx?topic=java&locale=en) says "Here is the list of the problems which are not guaranteed to be solvable in Java: 1220, 1275, 1306." Now 1220 may be removed from this list. Russian version of the FAQ slightly more close to the truth. It says that problems except 1220, 1275 and 1306 may be solved in Java _without_significant_difficulties_. And this statement is true. 1220 _may_ be solved in Java, but with much more difficulty than in Pascal or C++. great! how to C# ? how to C# ? Your solution 2525637 uses only 300 kb of memory. Probably it does nothing, but 750-300 kb is enough to get AC using right techniques. The most important is to not create objects. So no strings, only reusable arrays of characters. And probably you are to implement reading and writing classes over byte IO that do not use object creation. Your solution 2525637 uses only 300 kb of memory. Probably it does nothing. ------------------------ Yes, it's only: static void Main(){} but it uses 365KB memory. The most important is to not create objects. So no strings, only reusable arrays of characters. And probably you are to implement reading and writing classes over byte IO that do not use object creation. ------------------- i shall try. thank you very much. I solved this problem on Java. Memory < 1 М .Time was about 0.8 c. Without any arays!!! Are your can? =). Thanks to Fyodor Menshikov. He was rigth about limitation. Using recursive procedure like topological sorting. Recursion implicitly uses array (stack), so used memory will be the same. Edited by author 13.01.2009 23:26 And how? And how? Think. Look at memory compsumption of first solutions of the problem. if(A+B > 9) ..... Console.Write(last+1); if(A+B == 9) count++; ...... if(A+B < 9) Console.Write(last); but it's slow,so it's not a good way What is the answer for n=3000? According to my problem it is: 1112410638837951982681559213420228436655660132143101893639583499479104 8307860224498112075664780555124758923322998295448875554498944133575085 7206969739792707314008867553774340959765426840307082886757146900689409 1769558402678831747586833656908719011631685677289799215417532225045801 3194444896132535792828846054226294650004927200184834052327444607699483 6595280893152817992146653301160115779064762003728308491537220749832979 2557104621996394714041315150395706599135856376433569557036792447902521 76364500701 but i've got WA HELP! n=3000 6230944380615661730540866744905062220607354471963766287778397756065940 6962697903814082629320941801101660304581383981489487361062625347661816 5706321659264965023017203487210780255823880970691747085650866739360077 645709393425508719830393155473510779779930751 But I got wa too. 1322070819480806636890455259752144365965422032752148167664920368226828 5973467048995407783138506080619639097776968725823559509545821006189118 6534272525795367402762022519832080387801477422896484127439040011758861 8041128947815623094438061566173054086674490506178125480344405547054397 0388958174653682549161362208302685637785822902284163983078878969185564 0408489893760937324217184635993869 13220708194808066368904552597521443659654220327521481676649203682268285973467048 99540778313850608061963909777696872582355950954582100618911865342725257953674027 62022519832080387801477422896484127439040011758861804112894781562309443806156617 30540866744905061781254803444055470543970388958174653682549161362208302685637785 82290228416398307887896918556404084898937609373242171846359938695516765018940588 109060426089671438864102814350385648747165832010614366132173102768902855220001 78269792221766377248792586107312578551454955298456387837931004855964813172193821243390064215949238600077681954053753825948909941306968357700343451652009989159020094600778289423859975436358546313727455317042603649908448160723189846384364576128985442328158891806918309846544996297697505373844135967311576127112637752359444869773878802929985672496258464403635036929317966161945895754817512140406205791563756008285751669647079656658308372789688485874728678798223164136163414900736 When n=3000 my AC program print: 1322070819480806636890455259752144365965422032752148167664920368226828597346704899540778313850608061963909777696872582355950954582100618911865342725257953674027620225198320803878014774228964841274390400117588618041128947815623094438061566173054086674490506178125480344405547054397038895817465368254916136220830268563778582290228416398307887896918556404084898937609373242171846359938695516765018940588109060426089671438864102814350385648747165832010614366132173102768902855220001 Because correct is: 1322070819480806636890455259752144365965422032752148167664920368226828597346704899540778313850608061963909777696872582355950954582100618911865342725257953674027620225198320803878014774228964841274390400117588618041128947815623094438061566173054086674490506178125480344405547054397038895817465368254916136220830268563778582290228416398307887896918556404084898937609373242171846359938695516765018940588109060426089671438864102814350385648747165832010614366132173102768902855220001 How Can I show the longest value with all digits. Now I show for n=3000 1.32207e+477 I use long double. somebody can help me???? Use array friend, write your own multiply function. Timus array max size = 64 K (or i may wrong) which means you can create char array[64000] store up to 64K digit Edited by author 16.04.2007 20:37 Edited by author 16.04.2007 20:56 size of array is not limited. if you need you can create array of any size. you must to implemet your own multiplication. algorithm is the same as you do it in your exercise book if in pascal you can use extended F[i] = Max[F[i-j]*j} (0<i<=20) 1 (i=0) F[i-3]*3 (i>20) In this way,you can solve the problem in O(n^2). Edited by author 28.01.2009 03:58 I had MLE #1 with 2 arrays: (C ++) int a[ 100000 ], short b[ 100000 ]; How to use 1 array instead of two??? int a[ 100000 ], short b[ 1000 ]; I know solution that gets AC with parameter EPS from 1e-0 to 1e-15 (1e+1 and 1e-16 get WA). It is _very_ strange that tests allow such inaccuracy. It depends on the way use solve the problem. If you do all calculations in integers, any EPS from 1e-0 to 1e-15 will give right answer =) If you do all calculations in integers, any EPS from 1e-0 to 1e-15 will give right answer =) How can you do all calculations in integers if there are a lot of real numbers in input and no limits on number of digits after decimal point? I use : int a[ 100000 ]; short num[ 100000 ]; And I have MLE #1!!! 100000 * 4 + 100000 * 2 = 600000 bytes + plus memory for your programm. Memory limit can be 750000 bytes instead of 750 Kb. How to avoid MLE??? You use too much memory. Try to fit into one array int[100000]... Can you prompt me? I can't think up how to do it. For example, look at corresponding section in D. Knuth's book (something about several stacks in one memory segment) I can't find it!? Can you tell me any idea??? Just use the "realloc()" function ;-) just why WA 1? #include<iostream> using namespace std; int main() { int l, n, k; cin>>l>>n; while(n--){ cin>>k; if(l<=k) {cout<<"YES"; return 0;} l-=k; l+=l%k; } cout<<"NO"; return 0; } import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Reader; import java.io.StreamTokenizer; import java.io.Writer; import java.util.Stack; import java.util.LinkedList; public class ACM1001 {
Reader reader = null; Writer writer = null; StreamTokenizer in = null; PrintWriter out = null; boolean oj = System.getProperty("ONLINE_JUDGE") != null; Stack<Double> dInput = null; LinkedList<Double> dOuput = null; BufferedReader bufReader= null;
public void run() { try{ reader = oj ? new InputStreamReader(System.in) : new FileReader("input1001.txt"); bufReader= new BufferedReader(reader); in = new StreamTokenizer(bufReader); writer = new OutputStreamWriter(System.out); out = new PrintWriter(writer);
dInput = new Stack<Double>(); dOuput = new LinkedList<Double>(); int j = in.nextToken(); while(j != StreamTokenizer.TT_EOF) { if(j == StreamTokenizer.TT_NUMBER) { dInput.push(in.nval); } j = in.nextToken(); } solve(); out.flush(); } catch (Exception e) { e.printStackTrace(); } }
public void solve() { //long 类型的最大值的常量,该值为 2^63 -1 至 2^-63 //double:(2-2-52)·2^1023 至 2^-1074 while(!dInput.isEmpty()){ double dva = dInput.pop(); double x=Math.sqrt(dva); dOuput.add(x); } //BigDecimal 未不可变的、任意精度的有符号十进制数 while(!dOuput.isEmpty()){ System.out.printf("%.4f \n",dOuput.removeFirst()); } } /** * @param args */ public static void main(String[] args) { new ACM1001().run(); } } import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Reader; import java.io.StreamTokenizer; import java.io.Writer; import java.util.Stack; import java.util.LinkedList; public class ACM1001 {
Reader reader = null; Writer writer = null; StreamTokenizer in = null; PrintWriter out = null; boolean oj = System.getProperty("ONLINE_JUDGE") != null; Stack<Double> dInput = null; LinkedList<Double> dOuput = null; BufferedReader bufReader= null;
public void run() { try{ reader = oj ? new InputStreamReader(System.in) : new FileReader("input1001.txt"); bufReader= new BufferedReader(reader); in = new StreamTokenizer(bufReader); writer = new OutputStreamWriter(System.out); out = new PrintWriter(writer);
dInput = new Stack<Double>(); dOuput = new LinkedList<Double>(); int j = in.nextToken(); while(j != StreamTokenizer.TT_EOF) { if(j == StreamTokenizer.TT_NUMBER) { dInput.push(in.nval); } j = in.nextToken(); } solve(); out.flush(); } catch (Exception e) { e.printStackTrace(); } }
public void solve() { //long 类型的最大值的常量,该值为 2^63 -1 至 2^-63 //double:(2-2-52)·2^1023 至 2^-1074 while(!dInput.isEmpty()){ double dva = dInput.pop(); double x=Math.sqrt(dva); dOuput.add(x); } //BigDecimal 未不可变的、任意精度的有符号十进制数 while(!dOuput.isEmpty()){ System.out.printf("%.4f \n",dOuput.removeFirst()); } } /** * @param args */ public static void main(String[] args) { new ACM1001Solve2().run(); } } class ACM1001Solve2 extends ACM1001 { public void run() { try{ reader = oj ? new InputStreamReader(System.in) : new FileReader("input1001.txt"); bufReader= new BufferedReader(reader); in = new StreamTokenizer(bufReader); writer = new OutputStreamWriter(System.out); out = new PrintWriter(writer);
dInput = new Stack<Double>(); int j = in.nextToken(); while(j != StreamTokenizer.TT_EOF) { if(j == StreamTokenizer.TT_NUMBER) { solve2(in.nval); } j = in.nextToken(); } bufReader.close(); bufReader = null; reader.close(); reader = null; while(!dInput.isEmpty()){ System.out.printf("%.4f \n",dInput.pop()); } out.flush(); dInput.clear(); dInput = null; out = null; writer.close(); writer = null; } catch (Exception e) { e.printStackTrace(); } finally{ reader = null; writer = null; } }
private void solve2(double nn) { double x=Math.sqrt(nn); dInput.push(x); } }//end class ACM1001Solve2 It's not my first task here on Timus. But for this task I had WA #1. I invented a lot of tests and all of them is solved by my DP solution (and sample of course). No chars in answer except '\n'. Anybody can tell me what's can be wrong? Mine solution have WA1 too... It is very strange because test Nr1 must be the test from the sample... don't must. but usualy test "Nr1 be the test from the sample..." Edited by author 25.12.2006 09:25 here test #1 is not the sample test who can give me some test data? Edited by author 28.03.2009 01:14 Edited by author 28.03.2009 01:14 7 3 6 8 3 8 1 7 0 3 4 0 6 1 9 6 If you draw this polygon on paper, you understand yours mistake ;) Edited by author 06.03.2009 21:05 By the way the correct answer is 0.38528021 I have WA 12 too. I understood why my solution is wrong. So, what the idea of right solution? Nart27 has post the 10 test cases of this problem. I got wrong answer of test10, following is the comparison between my result and contents of Nart27's "phone9.out": ________________________________phone9.out abbacc eeeddfd rrspps uuuvvtt xwwwwx zqooozq wyywxwy tuvvvu sprrrrp ffefed ababbab 222222 3333333 777777 8888888 999999 0000000 9999999 888888 7777777 333333 2222222 ________________________________my result 222222 3333333 777777 8888888 999999 0000000 9999999 888888 7777777 333333 2222222 ccacbb eeddfed ppsrpr vvvuuuv ywwyxx zzzoqoo xxxwxxw tvuvvt prppspr deedde baccabc ________________________________ Thers are sentences like this in the problem description: "If there are more solutions having the minimum number of words, you can choose any single one of them." can anybody tell me is it really the case? Sorry it's my fault, there is an other problem in my program. I've got ac! this test help me find my bug... in: 4 5 3 1 7 9 out: 20 12 |
|
|