{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n div.illustration {\n float: right;\n padding-left: 20px;\n }\n div.illustration .illustration {\n width: 100%;\n border-radius: 4px;\n }\n pre {\n display: block;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n color: #333;\n word-break: break-all;\n word-wrap: break-word;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cp\u003ePsychologists at Wassamatta University believe that humans\n are able to more easily deal with words than with numbers. So\n they have devised experiments to find out if this is true. In\n an interesting twist, one of their experiments deals with using\n words which represent numbers. Rather than adding numbers, they\n want to add words. You are a research programmer on the\n project, and your job is to write a program that demonstrates\n this ability.\u003c/p\u003e\n\n \u003ch2\u003eInput\u003c/h2\u003e\n\n \u003cp\u003eInput is a sequence of up to \u003cspan class\u003d\"tex2jax_process\"\u003e$2000$\u003c/span\u003e commands, one per line, ending\n at end of file. Each command is a definition, a calculation, or\n a clear. All tokens within a command are separated by single\n spaces.\u003c/p\u003e\n\n \u003cp\u003eA definition has the format \u003ctt class\u003d\"tt\"\u003edef x y\u003c/tt\u003e\n where \u003ctt class\u003d\"tt\"\u003ex\u003c/tt\u003e is a variable name and \u003ctt class\u003d\"tt\"\u003ey\u003c/tt\u003e is a an integer in the range \u003cspan class\u003d\"tex2jax_process\"\u003e$[-1\\, 000, 1\\, 000]$\u003c/span\u003e. No two\n variables are ever defined to have the same numeric value at\n the same time. If \u003ctt class\u003d\"tt\"\u003ex\u003c/tt\u003e had been defined\n previously, defining it again erases its old definition.\n Variable names are up to \u003cspan class\u003d\"tex2jax_process\"\u003e$30$\u003c/span\u003e lowercase characters, each\n character from the range a to z.\u003c/p\u003e\n\n \u003cp\u003eA calculation command starts with the word \u003ctt class\u003d\"tt\"\u003ecalc\u003c/tt\u003e, and is followed by one to \u003cspan class\u003d\"tex2jax_process\"\u003e$15$\u003c/span\u003e more variable names separated by\n addition or subtraction operators. The end of a \u003ctt class\u003d\"tt\"\u003ecalc\u003c/tt\u003e command is an equals sign. For example:\u003c/p\u003e\n\n \u003ccenter\u003e\n \u003ctt class\u003d\"tt\"\u003ecalc foo + bar - car \u003d\u003c/tt\u003e\n \u003c/center\u003e\n\n \u003cp\u003eThe \u003ctt class\u003d\"tt\"\u003eclear\u003c/tt\u003e command instructs your program\n to forget all of its definitions.\u003c/p\u003e\n\n \u003ch2\u003eOutput\u003c/h2\u003e\n\n \u003cp\u003eYour program should produce no output for definitions, but\n for calculations it should produce the value of the\n calculation. If there is not a word for the result, or some\n word in the calculation has not been defined, then the result\n of the calculation should be \u003ctt class\u003d\"tt\"\u003eunknown\u003c/tt\u003e. The\n word \u003ctt class\u003d\"tt\"\u003eunknown\u003c/tt\u003e is never used as a variable in\n the input.\u003c/p\u003e\n\n \u003ch2\u003eSample 1\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\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\u003edef foo 3\ncalc foo + bar \u003d\ndef bar 7\ndef programming 10\ncalc foo + bar \u003d\ndef is 4\ndef fun 8\ncalc programming - is + fun \u003d\ndef fun 1\ncalc programming - is + fun \u003d\nclear\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003efoo + bar \u003d unknown\nfoo + bar \u003d programming\nprogramming - is + fun \u003d unknown\nprogramming - is + fun \u003d bar\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n "}}]}