{"id":683,"date":"2019-09-07T16:21:53","date_gmt":"2019-09-07T08:21:53","guid":{"rendered":"http:\/\/149.129.74.185\/?p=683"},"modified":"2019-09-08T19:41:02","modified_gmt":"2019-09-08T11:41:02","slug":"pat%e5%ad%a6%e5%88%b0%e4%ba%86-2019-9-7","status":"publish","type":"post","link":"http:\/\/www.magicmipamipa.com\/?p=683","title":{"rendered":"PAT\u5b66\u5230\u4e86 2019\/9\/7"},"content":{"rendered":"<p><span style=\"font-size: 14px;\">\u30104\u53f7\u505a\u4e86\u4e00\u4e0bPAT\u7684\u4ee3\u7801\u4ed3\u5e93\uff0c\u6211\u50cf\u4e00\u4e2a\u50bb\u5b50\u5f00\u7740vs\u63d0\u4ea4git\uff0c\u7ed3\u679c\u4e00\u76f4\u63d0\u793acommit failed\uff0c\u7528shell\u4e00\u4e2a\u4e2a\u6587\u4ef6add\u624d\u53d1\u73b0\u662f\u81ea\u5df1\u73b0\u5728\u6b63\u5728\u5199\u7684\u9898\u7684\u6587\u4ef6\u88ab\u9501\u4f4f\u4e86=\/=\uff0cPAT\u6559\u7ed9\u4e86\u6211\u5f88\u591a\uff0c\u6bd4\u5982\u4e00\u5b9a\u4e0d\u80fd\u53d8\u6210\u4e00\u4e2a\u5f31\u667a\u3002 \u3011<\/span><\/p>\n<p>1.Dijkstra<\/p>\n<pre class=\"language-cpp\"><code>void Dijkstra() {\r\n\twhile (!visited[D]) {\r\n\t\tint v = -1, min = INF;\r\n\t\tfor (int i = 0; i &lt; N; i++) {\r\n\t\t\tif (!visited[i] &amp;&amp; dis[i] &lt; min) {\r\n\t\t\t\tv = i;\r\n\t\t\t\tmin = dis[i];\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (v == -1) return;\/\/\u672a\u8054\u901a\r\n\t\tvisited[v] = true;\/\/\u8bbf\u95ee\u8be5\u70b9\r\n\t\tfor ( edge&amp;e : graph[v] ) {\r\n\t\t\tif (!visited[e.v] &amp;&amp; dis[e.v] &gt; dis[v] + e.dis ){\r\n\t\t\t\tdis[e.v] = dis[v] + e.dis;\r\n\t\t\t\tcost[e.v] = cost[v] + e.cost;\r\n\t\t\t\tpathLast[e.v] = v;\r\n\t\t\t}\r\n\t\t\telse if(dis[e.v] == dis[v]+ e.dis &amp;&amp; cost[e.v]&gt; cost[v] + e.cost){\/\/\u82b1\u8d39\u66f4\u5c11\r\n\t\t\t\tcost[e.v] = cost[v] + e.cost;\r\n\t\t\t\tpathLast[e.v] = v;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}<\/code><\/pre>\n<p>2.Dijkstra\u6240\u9700\u6570\u636e\u7ed3\u6784<\/p>\n<pre class=\"language-cpp\"><code>struct edge {\r\n\tint v,dis,cost;\/\/\u672b\u7aef\u7ed3\u70b9\u3001\u8ddd\u79bb\u3001\u6743\u91cd\r\n\tedge( int _v, int _d, int _c) {\r\n\t\tv = _v;\r\n\t\tdis = _d;\r\n\t\tcost = _c;\r\n\t}\r\n};\r\nvector&lt;vector&lt;edge&gt; &gt; graph(505);\r\nint dis[505], cost[505], pathLast[505];\/\/\u8d77\u70b9\u5230\u8be5\u70b9\u7684\u8ddd\u79bb,\u8d77\u70b9\u5230\u8be5\u70b9\u7684\u6700\u5c0f\u6743\u91cd,\u8d77\u70b9\u5230\u8be5\u70b9\u7684\u7236\u8282\u70b9\r\nbool visited[505] = {false};<\/code><\/pre>\n<p>3.Dijkstra\u521d\u59cb\u5316<\/p>\n<pre class=\"language-cpp\"><code>\tfor (int i = 0; i &lt; M; i++) {\r\n\t\tscanf(\"%d %d %d %d\", &amp;a, &amp;b, &amp;c, &amp;d);\r\n\t\tgraph[a].push_back(edge(b, c, d));\r\n\t\tgraph[b].push_back(edge(a, c, d));\r\n\t}\r\n\tfill(dis, dis + N, INF);\r\n\tfill(cost, cost + N, INF);\r\n\tdis[S] = cost[S] = 0;\r\n\tDijkstra();<\/code><\/pre>\n<p><span style=\"font-size: 14px;\">4.\u56de\u6587\u4e32\u7684\u5e38\u7528\u51fd\u6570<\/span><\/p>\n<p><span style=\"font-size: 14px;\"><code>string.substr(pos,n);<\/code><\/span><\/p>\n<p><span style=\"font-size: 14px;\"><code>reverse(string.begin(),string.end());<\/code><\/span><\/p>\n<p><span style=\"font-size: 14px;\">5 .\u5927\u6570\u8fd0\u7b97\u7684\u7ed3\u679c\u5bf91000000007\u53d6\u6a21 \u9632\u6b62\u6ea2\u51fa<\/span><\/p>\n<p><span style=\"font-size: 14px;\">6. getchar()\u5403\u6389getline()\u524d\u9762\u7684\u56de\u8f66<\/span><\/p>\n<p><span style=\"font-size: 14px;\">7.\u51e0\u4e2a\u57fa\u7840\u6392\u5e8f\uff1a<\/span><\/p>\n<blockquote>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">\u76f4\u63a5\u63d2\u5165\u6392\u5e8f\u7684\u7b97\u6cd5\u601d\u8def\uff1a<\/span><\/div>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">\uff081\uff09 \u8bbe\u7f6e\u76d1\u89c6\u54e8r[0]\uff0c\u5c06\u5f85\u63d2\u5165\u8bb0\u5f55\u7684\u503c\u8d4b\u503c\u7ed9r[0]\uff1b<\/span><\/div>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">\uff082\uff09 \u8bbe\u7f6e\u5f00\u59cb\u67e5\u627e\u7684\u4f4d\u7f6ej\uff1b<\/span><\/div>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">\uff083\uff09 \u5728\u6570\u7ec4\u4e2d\u8fdb\u884c\u641c\u7d22\uff0c\u641c\u7d22\u4e2d\u5c06\u7b2cj\u4e2a\u8bb0\u5f55\u540e\u79fb\uff0c\u76f4\u81f3r[0].key\u2265r[j].key\u4e3a\u6b62\uff1b<\/span><\/div>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">\uff084\uff09 \u5c06r[0]\u63d2\u5165r[j+1]\u7684\u4f4d\u7f6e\u4e0a\u3002<\/span><\/div>\n<\/blockquote>\n<div label-module=\"para\"><\/div>\n<div label-module=\"para\">\n<blockquote>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">\u5f52\u5e76\u64cd\u4f5c(merge)\uff0c\u4e5f\u53eb\u5f52\u5e76\u7b97\u6cd5\uff0c\u6307\u7684\u662f\u5c06\u4e24\u4e2a\u987a\u5e8f\u5e8f\u5217\u5408\u5e76\u6210\u4e00\u4e2a\u987a\u5e8f\u5e8f\u5217\u7684\u65b9\u6cd5\u3002<\/span><\/div>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">\u5982\u3000\u8bbe\u6709\u6570\u5217{6\uff0c202\uff0c100\uff0c301\uff0c38\uff0c8\uff0c1}<\/span><\/div>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">\u521d\u59cb\u72b6\u6001\uff1a6,202,100,301,38,8,1<\/span><\/div>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">\u7b2c\u4e00\u6b21\u5f52\u5e76\u540e\uff1a{6,202},{100,301},{8,38},{1}\uff0c\u6bd4\u8f83\u6b21\u6570\uff1a3\uff1b<\/span><\/div>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">\u7b2c\u4e8c\u6b21\u5f52\u5e76\u540e\uff1a{6,100,202,301}\uff0c{1,8,38}\uff0c\u6bd4\u8f83\u6b21\u6570\uff1a4\uff1b<\/span><\/div>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">\u7b2c\u4e09\u6b21\u5f52\u5e76\u540e\uff1a{1,6,8,38,100,202,301},\u6bd4\u8f83\u6b21\u6570\uff1a4\uff1b<\/span><\/div>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">\u603b\u7684\u6bd4\u8f83\u6b21\u6570\u4e3a\uff1a3+4+4=11\uff1b<\/span><\/div>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">\u9006\u5e8f\u6570\u4e3a14\uff1b<\/span><\/div>\n<\/blockquote>\n<\/div>\n<div class=\"para-title level-2\" label-module=\"para-title\"><\/div>\n<blockquote>\n<div label-module=\"para-title\">\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">\u5feb\u901f\u6392\u5e8f\u7b97\u6cd5\u901a\u8fc7\u591a\u6b21\u6bd4\u8f83\u548c\u4ea4\u6362\u6765\u5b9e\u73b0\u6392\u5e8f\uff0c\u5176\u6392\u5e8f\u6d41\u7a0b\u5982\u4e0b\uff1a<sup class=\"sup--normal\" data-sup=\"2\" data-ctrmap=\":2,\">\u00a0<\/sup><\/span><a name=\"ref_2\"><\/a><a name=\"ref_2\"><\/a><a name=\"ref_2\"><\/a><a name=\"ref_2\"><\/a><\/div>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">(1)\u9996\u5148\u8bbe\u5b9a\u4e00\u4e2a\u5206\u754c\u503c\uff0c\u901a\u8fc7\u8be5\u5206\u754c\u503c\u5c06\u6570\u7ec4\u5206\u6210\u5de6\u53f3\u4e24\u90e8\u5206\u3002<sup class=\"sup--normal\" data-sup=\"2\" data-ctrmap=\":2,\">\u00a0<\/sup><\/span><a name=\"ref_2\"><\/a><a name=\"ref_2\"><\/a><a name=\"ref_2\"><\/a><a name=\"ref_2\"><\/a><\/div>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">(2)\u5c06\u5927\u4e8e\u6216\u7b49\u4e8e\u5206\u754c\u503c\u7684\u6570\u636e\u96c6\u4e2d\u5230\u6570\u7ec4\u53f3\u8fb9\uff0c\u5c0f\u4e8e\u5206\u754c\u503c\u7684\u6570\u636e\u96c6\u4e2d\u5230\u6570\u7ec4\u7684\u5de6\u8fb9\u3002\u6b64\u65f6\uff0c\u5de6\u8fb9\u90e8\u5206\u4e2d\u5404\u5143\u7d20\u90fd\u5c0f\u4e8e\u6216\u7b49\u4e8e\u5206\u754c\u503c\uff0c\u800c\u53f3\u8fb9\u90e8\u5206\u4e2d\u5404\u5143\u7d20\u90fd\u5927\u4e8e\u6216\u7b49\u4e8e\u5206\u754c\u503c\u3002<\/span><a name=\"ref_2\"><\/a><a name=\"ref_2\"><\/a><a name=\"ref_2\"><\/a><a name=\"ref_2\"><\/a><\/div>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">(3)\u7136\u540e\uff0c\u5de6\u8fb9\u548c\u53f3\u8fb9\u7684\u6570\u636e\u53ef\u4ee5\u72ec\u7acb\u6392\u5e8f\u3002\u5bf9\u4e8e\u5de6\u4fa7\u7684\u6570\u7ec4\u6570\u636e\uff0c\u53c8\u53ef\u4ee5\u53d6\u4e00\u4e2a\u5206\u754c\u503c\uff0c\u5c06\u8be5\u90e8\u5206\u6570\u636e\u5206\u6210\u5de6\u53f3\u4e24\u90e8\u5206\uff0c\u540c\u6837\u5728\u5de6\u8fb9\u653e\u7f6e\u8f83\u5c0f\u503c\uff0c\u53f3\u8fb9\u653e\u7f6e\u8f83\u5927\u503c\u3002\u53f3\u4fa7\u7684\u6570\u7ec4\u6570\u636e\u4e5f\u53ef\u4ee5\u505a\u7c7b\u4f3c\u5904\u7406\u3002<\/span><a name=\"ref_2\"><\/a><a name=\"ref_2\"><\/a><a name=\"ref_2\"><\/a><a name=\"ref_2\"><\/a><\/div>\n<div class=\"para\" label-module=\"para\"><span style=\"font-size: 14px;\">(4)\u91cd\u590d\u4e0a\u8ff0\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u770b\u51fa\uff0c\u8fd9\u662f\u4e00\u4e2a\u9012\u5f52\u5b9a\u4e49\u3002\u901a\u8fc7\u9012\u5f52\u5c06\u5de6\u4fa7\u90e8\u5206\u6392\u597d\u5e8f\u540e\uff0c\u518d\u9012\u5f52\u6392\u597d\u53f3\u4fa7\u90e8\u5206\u7684\u987a\u5e8f\u3002\u5f53\u5de6\u3001\u53f3\u4e24\u4e2a\u90e8\u5206\u5404\u6570\u636e\u6392\u5e8f\u5b8c\u6210\u540e\uff0c\u6574\u4e2a\u6570\u7ec4\u7684\u6392\u5e8f\u4e5f\u5c31\u5b8c\u6210\u4e86\u3002<\/span><\/div>\n<\/div>\n<\/blockquote>\n<div label-module=\"para\"><span style=\"font-size: 14px;\">8.\u683c\u5f0f\u68c0\u6d4b<\/span><\/div>\n<div label-module=\"para\"><span style=\"font-size: 14px;\"><code>sscafn(formalstr,\"%format\",&amp;deststr);<\/code>\u8bfb\u53d6\u6307\u5b9a\u683c\u5f0f\u7684\u6570\u636e<\/span><\/div>\n<div label-module=\"para\"><span style=\"font-size: 14px;\"><code>sprintf(deststr,\"%format\",formalstr);<\/code>\u5c06\u6307\u5b9a\u683c\u5f0f\u6570\u636e\u5199\u5165\u5b57\u7b26\u4e32<\/span><\/div>\n<div label-module=\"para\"><span style=\"font-size: 14px;\">\u5bf9\u6bd4\u4e24\u4e2a\u7684\u7ed3\u679c \u5373\u53ef\uff08compare\u6216\u9010\u4f4d\uff0c\u4e0d\u8981\u7528\u7b49\u53f7\uff09<\/span><\/div>\n<div label-module=\"para\"><\/div>\n<div label-module=\"para\"><span style=\"font-size: 14px;\">9.\u5224\u65ad\u662f\u7d20\u6570\u7684\u6a21\u677f<\/span><\/div>\n<div label-module=\"para\">\n<pre class=\"language-cpp\"><code>bool isprime(int a) {\r\n\tif (a == 1) return false;\r\n\tfor (int i = 2; i &lt;= sqrt(a); i++) {\r\n\t\tif (a % i == 0) return false;\r\n\t}\r\n\treturn true;\r\n}<\/code><\/pre>\n<\/div>\n<div label-module=\"para\">10.\u5224\u65ad\u662f\u6570\u5b57\u6216\u5b57\u6bcd\u65f6\uff0c\u53ef\u7528cctype\u7684<code>isalnum(string)<\/code><\/div>\n<div label-module=\"para\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u30104\u53f7\u505a\u4e86\u4e00\u4e0bPAT\u7684\u4ee3\u7801\u4ed3\u5e93\uff0c\u6211\u50cf\u4e00\u4e2a\u50bb\u5b50\u5f00\u7740vs\u63d0\u4ea4git\uff0c\u7ed3\u679c\u4e00\u76f4\u63d0\u793acommit faile [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16,17],"tags":[],"_links":{"self":[{"href":"http:\/\/www.magicmipamipa.com\/index.php?rest_route=\/wp\/v2\/posts\/683"}],"collection":[{"href":"http:\/\/www.magicmipamipa.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.magicmipamipa.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.magicmipamipa.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.magicmipamipa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=683"}],"version-history":[{"count":3,"href":"http:\/\/www.magicmipamipa.com\/index.php?rest_route=\/wp\/v2\/posts\/683\/revisions"}],"predecessor-version":[{"id":687,"href":"http:\/\/www.magicmipamipa.com\/index.php?rest_route=\/wp\/v2\/posts\/683\/revisions\/687"}],"wp:attachment":[{"href":"http:\/\/www.magicmipamipa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.magicmipamipa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=683"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.magicmipamipa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}