{"id":409,"date":"2019-06-09T17:41:16","date_gmt":"2019-06-09T09:41:16","guid":{"rendered":"http:\/\/fankasy.xyz\/?p=409"},"modified":"2019-06-09T17:41:16","modified_gmt":"2019-06-09T09:41:16","slug":"noj1005%e5%a4%9a%e9%a1%b9%e5%bc%8f%e5%8a%a0%e6%b3%95","status":"publish","type":"post","link":"http:\/\/fankasy.xyz\/index.php\/2019\/06\/09\/noj1005%e5%a4%9a%e9%a1%b9%e5%bc%8f%e5%8a%a0%e6%b3%95\/","title":{"rendered":"NOJ1005\u591a\u9879\u5f0f\u52a0\u6cd5"},"content":{"rendered":"<pre>NOJ1005 \u591a\u9879\u5f0f\u52a0\u6cd5\r\n\uff08\u4ee3\u7801\u901a\u8fc7\u6d4b\u8bd5\uff0c\u5de8\u5751\u5728\u4e8e\u5168\u662f0\u7684\u65f6\u5019\u4e5f\u8981\u8f93\u51fa0\uff09\r\n#include\r\n#include\r\n#include\r\n#define N 200\r\n\r\nint main()\r\n{\r\n    int ex;\r\n    int counttt = 2;\r\n    int exp = N;\r\n    int value = 0;\r\n    int List[2][N] = { 0 };\r\n    \/\/input list\r\n    while (counttt-- &gt; 0)\r\n    {\r\n        exp = N;\r\n        while (exp!=-1)\r\n        {\r\n            scanf(\"%d %d\", &amp;value, &amp;exp);\r\n            if (exp == -1)\r\n                break;\r\n            List[counttt][exp] = value;\r\n        }\r\n    }\r\n\r\n    \/\/fitst list\r\n    for (ex = N-1; ex &gt;= 0; ex--)\r\n    {\r\n        if (ex == 0 &amp;&amp; List[1][ex] == 0)\r\n            printf(\"%d\", List[1][ex]);\r\n        if (List[1][ex] == 0)\r\n            continue;\r\n        if (List[1][ex] == 1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"X\");\r\n            else if (ex == 0)\r\n                printf(\"1\");\r\n            else\r\n                printf(\"X^%d\", ex);\r\n            break;\r\n        }\r\n        if (List[1][ex] == -1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"-X\");\r\n            else if (ex == 0)\r\n                printf(\"-1\");\r\n            else\r\n                printf(\"-X^%d\", ex);\r\n            break;\r\n        }\r\n        if (List[1][ex] &gt; 1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"%dX\",List[1][ex]);\r\n            else if (ex == 0)\r\n                printf(\"%d\",List[1][ex]);\r\n            else\r\n                printf(\"%dX^%d\",List[1][ex], ex);\r\n            break;\r\n        }\r\n        if (List[1][ex] &lt; -1) { if (ex == 1) printf(\"%dX\", List[1][ex]); else if (ex == 0) printf(\"%d\", List[1][ex]); else printf(\"%dX^%d\", List[1][ex], ex); break; } } for (ex--; ex &gt;= 0; ex--)\r\n    {\r\n        if (List[1][ex] == 0)\r\n            continue;\r\n        if (List[1][ex] == 1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"+X\");\r\n            else if (ex == 0)\r\n                printf(\"+1\");\r\n            else\r\n                printf(\"+X^%d\", ex);\r\n        }\r\n        if (List[1][ex] == -1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"-X\");\r\n            else if (ex == 0)\r\n                printf(\"-1\");\r\n            else\r\n                printf(\"-X^%d\", ex);\r\n        }\r\n        if (List[1][ex] &gt; 1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"+%dX\", List[1][ex]);\r\n            else if (ex == 0)\r\n                printf(\"+%d\", List[1][ex]);\r\n            else\r\n                printf(\"+%dX^%d\", List[1][ex], ex);\r\n        }\r\n        if (List[1][ex] &lt; -1) { if (ex == 1) printf(\"%dX\", List[1][ex]); else if (ex == 0) printf(\"%d\", List[1][ex]); else printf(\"%dX^%d\", List[1][ex], ex); } } printf(\"\\n\"); \/\/second list for (ex = N - 1; ex &gt;= 0; ex--)\r\n    {\r\n        if (ex == 0 &amp;&amp; List[0][ex] == 0)\r\n            printf(\"%d\", List[0][ex]);\r\n        if (List[0][ex] == 0)\r\n            continue;\r\n        if (List[0][ex] == 1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"X\");\r\n            else if (ex == 0)\r\n                printf(\"1\");\r\n            else\r\n                printf(\"X^%d\", ex);\r\n            break;\r\n        }\r\n        if (List[0][ex] == -1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"-X\");\r\n            else if (ex == 0)\r\n                printf(\"-1\");\r\n            else\r\n                printf(\"-X^%d\", ex);\r\n            break;\r\n        }\r\n        if (List[0][ex] &gt; 1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"%dX\", List[0][ex]);\r\n            else if (ex == 0)\r\n                printf(\"%d\", List[0][ex]);\r\n            else\r\n                printf(\"%dX^%d\", List[0][ex], ex);\r\n            break;\r\n        }\r\n        if (List[0][ex] &lt; -1) { if (ex == 1) printf(\"%dX\", List[0][ex]); else if (ex == 0) printf(\"%d\", List[0][ex]); else printf(\"%dX^%d\", List[0][ex], ex); break; } } for (ex--; ex &gt;= 0; ex--)\r\n    {\r\n        if (List[0][ex] == 0)\r\n            continue;\r\n        if (List[0][ex] == 1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"+X\");\r\n            else if (ex == 0)\r\n                printf(\"+1\");\r\n            else\r\n                printf(\"+X^%d\", ex);\r\n        }\r\n        if (List[0][ex] == -1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"-X\");\r\n            else if (ex == 0)\r\n                printf(\"-1\");\r\n            else\r\n                printf(\"-X^%d\", ex);\r\n        }\r\n        if (List[0][ex] &gt; 1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"+%dX\", List[0][ex]);\r\n            else if (ex == 0)\r\n                printf(\"+%d\", List[0][ex]);\r\n            else\r\n                printf(\"+%dX^%d\", List[0][ex], ex);\r\n        }\r\n        if (List[0][ex] &lt; -1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"%dX\", List[0][ex]);\r\n            else if (ex == 0)\r\n                printf(\"%d\", List[0][ex]);\r\n            else\r\n                printf(\"%dX^%d\", List[0][ex], ex);\r\n        }\r\n\r\n    }\r\n    printf(\"\\n\");\r\n    \/\/Added list\r\n    for (ex = 0; ex &lt; N; ex++) List[1][ex] += List[0][ex]; \/\/print added list for (ex = N - 1; ex &gt;= 0; ex--)\r\n    {\r\n        if (ex == 0 &amp;&amp; List[1][ex] == 0)\r\n            printf(\"%d\", List[1][ex]);\r\n        if (List[1][ex] == 0)\r\n            continue;\r\n        if (List[1][ex] == 1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"X\");\r\n            else if (ex == 0)\r\n                printf(\"1\");\r\n            else\r\n                printf(\"X^%d\", ex);\r\n            break;\r\n        }\r\n        if (List[1][ex] == -1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"-X\");\r\n            else if (ex == 0)\r\n                printf(\"-1\");\r\n            else\r\n                printf(\"-X^%d\", ex);\r\n            break;\r\n        }\r\n        if (List[1][ex] &gt; 1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"%dX\", List[1][ex]);\r\n            else if (ex == 0)\r\n                printf(\"%d\", List[1][ex]);\r\n            else\r\n                printf(\"%dX^%d\", List[1][ex], ex);\r\n            break;\r\n        }\r\n        if (List[1][ex] &lt; -1) { if (ex == 1) printf(\"%dX\", List[1][ex]); else if (ex == 0) printf(\"%d\", List[1][ex]); else printf(\"%dX^%d\", List[1][ex], ex); break; } } for (ex--; ex &gt;= 0; ex--)\r\n    {\r\n        if (List[1][ex] == 0)\r\n            continue;\r\n        if (List[1][ex] == 1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"+X\");\r\n            else if (ex == 0)\r\n                printf(\"+1\");\r\n            else\r\n                printf(\"+X^%d\", ex);\r\n        }\r\n        if (List[1][ex] == -1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"-X\");\r\n            else if (ex == 0)\r\n                printf(\"-1\");\r\n            else\r\n                printf(\"-X^%d\", ex);\r\n        }\r\n        if (List[1][ex] &gt; 1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"+%dX\", List[1][ex]);\r\n            else if (ex == 0)\r\n                printf(\"+%d\", List[1][ex]);\r\n            else\r\n                printf(\"+%dX^%d\", List[1][ex], ex);\r\n        }\r\n        if (List[1][ex] &lt; -1)\r\n        {\r\n            if (ex == 1)\r\n                printf(\"%dX\", List[1][ex]);\r\n            else if (ex == 0)\r\n                printf(\"%d\", List[1][ex]);\r\n            else\r\n                printf(\"%dX^%d\", List[1][ex], ex);\r\n        }\r\n    }\r\n\r\n    printf(\"\\n\");\r\n    return 0;\r\n}\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>NOJ1005 \u591a\u9879\u5f0f\u52a0\u6cd5 \uff08\u4ee3\u7801\u901a\u8fc7\u6d4b\u8bd5\uff0c\u5de8\u5751\u5728\u4e8e\u5168\u662f0\u7684\u65f6\u5019\u4e5f\u8981\u8f93\u51fa0\uff09 #include #includ [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[17],"tags":[],"_links":{"self":[{"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/posts\/409"}],"collection":[{"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=409"}],"version-history":[{"count":0,"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/posts\/409\/revisions"}],"wp:attachment":[{"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=409"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}