{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eHave you used #define in C/C++ code like the code below?\u003cbr\u003e\u003cbr\u003e#include \u0026lt;stdio.h\u0026gt;\u003cbr\u003e#define MAX(a , b) ((a) \u0026gt; (b) ? (a) : (b))\u003cbr\u003eint main()\u003cbr\u003e{\u003cbr\u003e\u0026nbsp;\u0026nbsp;printf(\"%d\\n\" , MAX(2 + 3 , 4));\u003cbr\u003e\u0026nbsp;\u0026nbsp;return 0;\u003cbr\u003e}\u003cbr\u003e\u003cbr\u003eRun the code and get an output: 5, right?\u003cbr\u003eYou may think it is equal to this code:\u003cbr\u003e\u003cbr\u003e#include \u0026lt;stdio.h\u0026gt;\u003cbr\u003eint max(a , b) {\u0026nbsp;\u0026nbsp;return ((a) \u0026gt; (b) ? (a) : (b));\u0026nbsp;\u0026nbsp;}\u003cbr\u003eint main()\u003cbr\u003e{\u003cbr\u003e\u0026nbsp;\u0026nbsp;printf(\"%d\\n\" , max(2 + 3 , 4));\u003cbr\u003e\u0026nbsp;\u0026nbsp;return 0;\u003cbr\u003e}\u003cbr\u003e\u003cbr\u003eBut they aren\u0027t.Though they do produce the same anwser , they work in two different ways.\u003cbr\u003eThe first code, just replace the MAX(2 + 3 , 4) with ((2 + 3) \u0026gt; (4) ? (2 + 3) : 4), which calculates (2 + 3) twice.\u003cbr\u003eWhile the second calculates (2 + 3) first, and send the value (5 , 4) to function max(a , b) , which calculates (2 + 3) only once.\u003cbr\u003e\u003cbr\u003eWhat about MAX( MAX(1+2,2) , 3 ) ? \u003cbr\u003eRemember \"replace\".\u003cbr\u003eFirst replace: MAX( (1 + 2) \u0026gt; 2 ? (1 + 2) : 2 , 3)\u003cbr\u003eSecond replace: ( ( ( 1 + 2 ) \u0026gt; 2 ? ( 1 + 2 ) : 2 ) \u0026gt; 3 ? ( ( 1 + 2 ) \u0026gt; 2 ? ( 1 + 2 ) : 2 ) : 3).\u003cbr\u003eThe code may calculate the same expression many times like ( 1 + 2 ) above.\u003cbr\u003eSo #define isn\u0027t good.In this problem,I\u0027ll give you some strings, tell me the result and how many additions(加法) are computed.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line is an integer T(T\u0026lt;\u003d40) indicating case number.\u003cbr\u003eThe next T lines each has a string(no longer than 1000), with MAX(a,b), digits, \u0027+\u0027 only(Yes, there\u0027re no other characters).\u003cbr\u003eIn MAX(a,b), a and b may be a string with MAX(c,d), digits, \u0027+\u0027.See the sample and things will be clearer.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each case, output two integers in a line separated by a single space.Integers in output won\u0027t exceed 1000000."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e6\r\nMAX(1,0)\r\n1+MAX(1,0)\r\nMAX(2+1,3)\r\nMAX(4,2+2)\r\nMAX(1+1,2)+MAX(2,3)\r\nMAX(MAX(1+2,3),MAX(4+5+6,MAX(7+8,9)))+MAX(10,MAX(MAX(11,12),13))\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1 0\r\n2 1\r\n3 1\r\n4 2\r\n5 2\r\n28 14\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}