{"id":784,"date":"2019-09-24T23:34:49","date_gmt":"2019-09-24T15:34:49","guid":{"rendered":"http:\/\/149.129.74.185\/?p=784"},"modified":"2019-09-25T14:06:42","modified_gmt":"2019-09-25T06:06:42","slug":"pat-%e5%ad%a6%e5%88%b0%e4%ba%86-2019-9-24","status":"publish","type":"post","link":"http:\/\/www.magicmipamipa.com\/?p=784","title":{"rendered":"PAT \u5b66\u5230\u4e86 2019\/9\/24"},"content":{"rendered":"<p>1.\u5bf9map\u7684\u64cd\u4f5c\u6709\u4e86\u66f4\u65b0\u7684\u8ba4\u8bc6\uff01\uff01<\/p>\n<p>map&lt;string,vector&lt;int&gt;&gt; eg;<\/p>\n<p>eg[name].push_back(int);\u5c31\u53ef\u4ee5\u4e86\uff01\uff01<\/p>\n<p>2.set\u4f1a\u9ed8\u8ba4\u6392\u5e8f\u4ece\u5c0f\u5230\u5927\uff08\u5b57\u6bcd\u8868\u987a\u5e8f\uff09<\/p>\n<p>3.Dev-c++\u9700\u8981\u8bbe\u7f6e-std=c++11 \u8ba9Dev\u2f40\u6301C++11\u7279\u6027<\/p>\n<p>4.\u8f97\u8f6c\u76f8\u9664\u6cd5\u6c42\u6700\u5927\u516c\u7ea6\u6570<\/p>\n<pre class=\"language-cpp\"><code>int gcd(int a, int b) {\r\n return b == 0 ? a : gcd(b, a % b);\r\n}<\/code><\/pre>\n<p>5.&lt;cctype&gt; \u2fa5\u2faf\uff1a isalnum \u662f\u5b57\u2e9f\u6570\u5b57\uff1b isalpha \u662f\u5b57\u2e9f\uff1b isdigit \u662f\u6570\u5b57\uff1b isupper \u662f\u2f24\u5199\u5b57\u2e9f\uff1b islower \u662f\u2f29\u5199\u5b57\u2e9f\uff1b isblank \u662f\u7a7a\u683c\/tab\u952e\uff1b isspace \u662f\u7a7a\u683c\/tab\u952e\/\u56de\u2ecb<\/p>\n<p>6.win7\u76f4\u63a5\u901a\u8fc7\u2fcf\u6807\u53f3\u51fb\u2fca\u6846\u6700\u4e0a \u2faf\u7684\u83dc\u5355\u680f\u9009\u62e9\u590d\u5236\u548c\u7c98\u8d34\uff0c\u4e0d\u80fdctrl+v\/c<\/p>\n<p>7.dev\u4e2d\u67e5\u770b<code> vector<\/code> \u7684\u503c\uff1a<code> *(&amp;v[0])@3<\/code> \u2014\u2014\u5fc5\u987b\u5bf9 v[0] \u53d8\u6362\uff0c\u5148\u53d6\u5730\u5740\u518d\u53d6\u503c\uff0c<code> @<\/code> \u540e\u2faf\u7684\u6570\u5b57<code> 3<\/code> \u80fd\u8ba9 dev\u663e\u793a\u6570\u7ec4\u524d3\u4e2a\u7684\u503c\uff0c\u5728\u2f64\u8fd9\u4e2a\u4e4b\u524d\u8981\u5148\u5728 \u7f16\u8bd1\u9009\u9879-\u7f16\u8bd1\u5668\u2fa5\u2faf <code>-std=C++11<\/code><\/p>\n<p>8.<code>INT_MAX \u3001 INT_MIN \u3001 LLONG_MAX<\/code> \u5728 #include <climits> \u5934\u2f42\u4ef6\u2fa5\u2faf\uff0cint\u6700\u2f24\u503c\u4e3a2147483647\uff0c\u5171 10\u4f4d\u6570\u5b57\uff1b LLONG_MAX \u6700\u2f24\u503c\u670919\u4f4d\u6570\u5b57\uff0c\u4ee59\u5f00\u5934\u3002\u6240\u4ee5\u8bf4\u50a8\u5b5813\u4f4d\u7684\u5b66\u53f7\u53ef\u4ee5\u2f64 long long int \uff0c \u8f93\u51fa\u7684\u65f6\u5019\u4f7f\u2f64 %013lld<\/climits><\/p>\n<p>9.\u5bf9 <code>char c[15]<\/code> \u8fdb\u2f8f sort \u6392\u5e8f\u7684 <code>cmp(char a[], char b[])<\/code> \u51fd\u6570\u8981\u8fd9\u6837\u5199\uff1a <code>strcmp(a, b) &lt; 0<\/code> \uff0c\u56e0\u4e3a strcmp \u8fd4 \u56de\u7684\u4e0d\u662f -1 0 1 \u2f7d\u662f \u7b49\u4e8e0 \u2f29\u4e8e0 \u2f24\u4e8e0 \u7684\u67d0\u4e2a\u503c\uff0c strcmp \u5728\u5934\u2f42\u4ef6 #include <string.h> \u2fa5\u2faf<\/string.h><\/p>\n<p>10.\u5bf9 <code>vector v<\/code> \u6216\u8005<code> string v<\/code> \u8fdb\u2f8f sort \u6392\u5e8f\uff1a<code> sort(v.begin(), v.end(), cmp1);<\/code> \uff1b\u5bf9\u6570\u7ec4a\u8fdb\u2f8fsort\u6392 \u5e8f\uff1a <code>sort(a, a + n, cmp1);<\/code><\/p>\n<p>11.\u5c06\u2f17\u8fdb\u5236 a \u8f6c\u6362\u4e3a b \u8fdb\u5236\u6570\uff0c\u5f53 a \u4e0d\u7b49\u4e8e 0 \u65f6\uff0c\u5c06 <code>a%b<\/code> \u4ece\u540e\u5f80\u524d\u5012\u5e8f\u4fdd\u5b58\u4e0b\u6765\uff0c\u6bcf\u6b21\u4fdd\u5b58\u540e\u5c06 a\/b \u3002\u8fd9\u6837\u5012\u5e8f\u4fdd\u5b58\u7684\u6570\u5c31\u662f\u2f17\u8fdb\u5236 a \u5728 b \u8fdb\u5236\u4e0b\u7684\u7ed3\u679c\u3002<\/p>\n<p>12.\u5224\u65ad\u7d20\u6570<\/p>\n<pre class=\"language-cpp\"><code>\/\/ \u5224\u65adn\u662f\u5426\u4e3a\u7d20\u6570\r\nbool isprime(int n) {\r\n if (n &lt;= 1) return false;\r\n int sqr = int(sqrt(n * 1.0));\r\n for (int i = 2; i &lt;= sqr; i++)\r\n if (n % i == 0) return false;\r\n return true;\r\n}<\/code><\/pre>\n<p>13.\u8f93\u51fa\u8bed\u53e5\u5982\u679c\u6709 is \/ are\u3001\u52a0s \/ \u4e0d\u52a0s\u7684\u533a\u522b\u7684\u8bdd\u2f00\u5b9a\u8981\u5f53\u2f3c\uff0c\u2f50\u5982 &#8220;There is 1 account&#8221; \u548c &#8220;There are 2 accounts&#8221; \u662f\u4e0d\u540c\u7684\u8f93\u51fa\u8bed\u53e5<\/p>\n<p>14.\u79fb\u9664\u5b57\u7b26\u4e32s\u7684\u7b2c\u2f00\u4e2a\u5b57\u7b26\uff1a s.earse(s.begin()); \u5728\u5b57\u7b26\u4e32 s \u524d\u2faf\u589e\u52a0 n \u4e2a 0 \uff1a s.insert(0, n, &#8216;0&#8217;);<\/p>\n<p>15.\u2f64\u6570\u7ec4 hash[26] \u6216\u8005 hash[10] \u4fdd\u5b58\u67d0\u4e2a\u5b57\u2e9f\u6216\u8005\u6570\u5b57\u51fa\u73b0\u7684\u6b21\u6570\/\u662f\u5426\u66fe\u7ecf\u51fa\u73b0\u8fc7\uff1b\u2f64 hash[256] \u4fdd \u5b58\u67d0\u4e2a ASCII\u7801 \u5b57\u7b26\u662f\u5426\u51fa\u73b0\u8fc7\uff0c exist[10000] \u3001 cnt[10000] \u540c\u7406<\/p>\n<p>16.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u5bf9map\u7684\u64cd\u4f5c\u6709\u4e86\u66f4\u65b0\u7684\u8ba4\u8bc6\uff01\uff01 map&lt;string,vector&lt;int&gt; [&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\/784"}],"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=784"}],"version-history":[{"count":3,"href":"http:\/\/www.magicmipamipa.com\/index.php?rest_route=\/wp\/v2\/posts\/784\/revisions"}],"predecessor-version":[{"id":787,"href":"http:\/\/www.magicmipamipa.com\/index.php?rest_route=\/wp\/v2\/posts\/784\/revisions\/787"}],"wp:attachment":[{"href":"http:\/\/www.magicmipamipa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.magicmipamipa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=784"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.magicmipamipa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}