{"id":1615,"date":"2018-03-11T21:47:58","date_gmt":"2018-03-11T13:47:58","guid":{"rendered":"http:\/\/47.101.202.111\/?p=1615"},"modified":"2023-04-07T12:52:33","modified_gmt":"2023-04-07T04:52:33","slug":"pat%e4%b9%99%e7%ba%a7%e9%a2%98%e8%a7%a3%e6%8c%81%e7%bb%ad%e6%9b%b4%e6%96%b0","status":"publish","type":"post","link":"http:\/\/139.196.114.170\/?p=1615","title":{"rendered":"PAT- BASIC &#8211; 15POINTS"},"content":{"rendered":"<p>\u6807\u9898\u6807\u660e\u6ce8\u610f\u70b9\u53ca\u76f8\u5173\u542f\u53d1<\/p>\n<h4>1001 \u7b80\u5355\u8ba1\u6570\u5668<\/h4>\n<pre><code class=\"language-cpp\">#include&lt;iostream&gt;\nusing namespace std;\n\nint cnt = 0;\n\nint main(){\n    int n;\n    while(~scanf(&quot;%d&quot;, &amp;n)) {\n        while(n != 1) {\n            if(n % 2 == 0) n \/= 2;\n            else n = (3 * n + 1) \/ 2;\n            cnt++;\n        }\n        printf(&quot;%d&quot;, cnt);\n    }\n\n    return 0;\n}<\/code><\/pre>\n<h4>1006 \u53d6\u6a21\u4e0e\u57fa\u672c\u8f93\u5165\u8f93\u51fa<\/h4>\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\nusing namespace std;\n\nint main()\n{\n    int n;\n    int m[3];\n    while (~scanf(&quot;%d&quot;, &amp;n)) {\n\n        for (int i = 0; i &lt; 3; i++) {\n            m[i] = n % 10;\n            n \/= 10;\n        }\n\n        for (int i = 2; i &gt;= 0; i--) {\n            int j = 1;\n            while (m[i]--) {\n                if (i == 2) printf(&quot;B&quot;);\n                else if (i == 1) printf(&quot;S&quot;);\n                else printf(&quot;%d&quot;, j++);\n            }\n        }\n\n        printf(&quot;\\n&quot;);\n    }\n\n}<\/code><\/pre>\n<h4>1011 \u53d8\u91cf\u8303\u56f4<\/h4>\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\nusing namespace std;\n\nint main(){\n    long long a, b, c;\n    int n;\n    while(~scanf(&quot;%d&quot;, &amp;n)){\n        int i = 1;\n        while(n--){\n            scanf(&quot;%lld%lld%lld&quot;, &amp;a, &amp;b, &amp;c);\n            if(a + b &gt; c) printf(&quot;Case #%d: true&quot;, i++);\n            else printf(&quot;Case #%d: false&quot;, i++);\n            printf(&quot;\\n&quot;);\n        }\n    }\n    return 0;\n}<\/code><\/pre>\n<h4>1016 \u5927\u6574\u6570\u4e0e\u5341\u8fdb\u5236\u8ba1\u7b97<\/h4>\n<pre><code class=\"language-cpp\">#include&lt;iostream&gt;\nusing namespace std;\n\nlong long P(char x[], int y)\n{\n    long long sum = 0;\n    for(int i = 0; x[i]; i++)\n        if(x[i] - &#039;0&#039; == y)\n            sum = 10 * sum + y;\n    return sum;\n}\n\nint main() {\n    char a[10], c[10];\n    int b, d;\n    while(~scanf(&quot;%s%d%s%d&quot;, &amp;a, &amp;b, &amp;c, &amp;d))\n        printf(&quot;%lld\\n&quot;, P(a, b) + P(c, d));\n    return 0;\n}<\/code><\/pre>\n<h4>1021 \u7b80\u5355\u57fa\u6570\u6392\u5e8f\u601d\u60f3<\/h4>\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\n#include &lt;bits\/stdc++.h&gt;\nusing namespace std;\n\nint main() {\n    int n[10];\n    char s[1000];\n    memset(n, 0, sizeof(n));\n    while(~scanf(&quot;%s&quot;, &amp;s)) {\n        for(int i = 0; s[i]; i++)\n            n[s[i] - &#039;0&#039;]++;\n        for(int i = 0; i &lt; 10; i++)\n            if(n[i]) printf(&quot;%d:%d\\n&quot;, i, n[i]);\n    }\n    return 0;\n}<\/code><\/pre>\n<h4>1026 \u56db\u820d\u4e94\u5165\u53ca\u8f93\u51fa\u8865\u9f50<\/h4>\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\nusing namespace std;\n\nint main() {\n    int c1, c2;\n    while(~scanf(&quot;%d%d&quot;, &amp;c1, &amp;c2)) {\n        int s = (c2 - c1 + 50) \/ 100;\n        int hh = s \/ 3600;\n        int mm = s % 3600 \/ 60;\n        int ss = s % 60;\n        printf(&quot;%02d:%02d:%02d\\n&quot;, hh, mm, ss);\n    }\n    return 0;\n}<\/code><\/pre>\n<h4>1031 \u6ce8\u610f\u53d8\u91cf\u53d1\u751f\u53d8\u5316<\/h4>\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\nusing namespace std;\n\nint main() {\n    int w[] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};\n    char z[] = {&#039;1&#039;, &#039;0&#039;, &#039;X&#039;, &#039;9&#039;, &#039;8&#039;, &#039;7&#039;, &#039;6&#039;, &#039;5&#039;, &#039;4&#039;, &#039;3&#039;, &#039;2&#039;};\n    char s[18];\n    int n;\n    while(~scanf(&quot;%d&quot;, &amp;n)) {\n        int cnt = n;\n        while(n--) {\n            int sum = 0;\n            bool f = true;\n            scanf(&quot;%s&quot;, &amp;s);\n\n            for(int i = 0; i &lt; 17; i++) {\n                if(s[i] &gt;= &#039;0&#039; &amp;&amp; s[i] &lt;= &#039;9&#039;)\n                    sum += w[i] * (s[i] - &#039;0&#039;);\n                else { f = false; break;};\n            }\n\n            if(f &amp;&amp; z[sum % 11] == s[17]) cnt--;\n            else printf(&quot;%s\\n&quot;, s);\n        }\n        if(cnt == 0) printf(&quot;All passed\\n&quot;);\n    }\n    return 0;\n}<\/code><\/pre>\n<h4>1036 \u7a7a\u683c\u8f93\u51651\u578b\u5faa\u73af\u56db\u820d\u4e94\u5165<\/h4>\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\nusing namespace std;\n\nint main()\n{\n    int n;\n    char c;\n    scanf(&quot;%d %c&quot;, &amp;n, &amp;c);\n    int end = (n + 1) \/ 2;\n    for (int i = 1; i &lt;= end; i++) {\n        for (int j = 0; j &lt; n; j++) {\n            if (i == 1 || i == end) printf(&quot;%c&quot;, c);\n            else if (j == 0 || j == n - 1) printf(&quot;%c&quot;, c);\n            else printf(&quot; &quot;);\n        }\n        printf(&quot;\\n&quot;);\n    }\n\n    return 0;\n}<\/code><\/pre>\n<h4>1041 \u5faa\u73af\u4f53\u5185\u5b58\u5206\u914d\u53ca\u6307\u9488\u6570\u7ec4<\/h4>\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\nusing namespace std;\n\nint main()\n{\n    int n, m;\n    scanf(&quot;%d&quot;, &amp;n);\n    int exam[n + 1];\n    string atmt[n + 1];\n    while (n--)\n    {\n        int e, a;\n        char s[16];\n        scanf(&quot;%s%d%d&quot;, &amp;s, &amp;a, &amp;e);\n        exam[a] = e;\n        atmt[a] = s;\n    }\n\n    scanf(&quot;%d&quot;, &amp;m);\n    while (m--)\n    {\n        int t;\n        scanf(&quot;%d&quot;, &amp;t);\n        printf(&quot;%s %d\\n&quot;, atmt[t].c_str(), exam[t]);\n    }\n    return 0;\n}<\/code><\/pre>\n<h4>1046 \u53d8\u91cf\u5fc5\u8d4b\u521d\u503c\u53ca\u8003\u8651\u5f02\u6216\u5e94\u7528<\/h4>\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\nusing namespace std;\nint main() {\n    int n, a1, b1, a2, b2, c1 = 0, c2 = 0;\n    scanf(&quot;%d&quot;, &amp;n);\n    while(n--) {\n        scanf(&quot;%d%d%d%d&quot;, &amp;a1, &amp;b1, &amp;a2, &amp;b2);\n        int r = a1 + a2;\n        int d1 = r == b1;\n        int d2 = r == b2;\n        if(d1 &gt; d2) { c2++; continue; }\n        if(d1 &lt; d2) c1++;\n    }\n    printf(&quot;%d %d\\n&quot;, c1, c2);\n    return 0;\n}<\/code><\/pre>\n<h4>1051 \u6570\u5b66\u51fd\u6570\u3001\u8f93\u51fa\u5c0f\u6570\u820d\u5165\u3001\u7b80\u5316<\/h4>\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\n#include &lt;math.h&gt;\nusing namespace std;\n\nint main()\n{\n    double r1, p1, r2, p2, a, b;\n    scanf(&quot;%lf%lf%lf%lf&quot;, &amp;r1, &amp;p1, &amp;r2, &amp;p2);\n    a = r1 * r2 * cos(p1 + p2);\n    b = r1 * r2 * sin(p1 + p2);\n\n    if (a &lt; 0 &amp;&amp; a &gt; -0.005) a = 0.0;\n    if (b &lt; 0 &amp;&amp; b &gt; -0.005) b = 0.0;\n    printf(&quot;%.2f%+.2fi&quot;, a, b);\n\n    return 0;\n}<\/code><\/pre>\n<h4>1056 \u679a\u4e3e\u4e0b\u6807\u3001\u95ee\u9898\u8f6c\u5316<\/h4>\n<pre><code class=\"language-cpp\">int main() {\n    int n, a, sum = 0;\n    scanf(&quot;%d&quot;, &amp;n);\n    for (int i = 0; i &lt; n; i++) {\n        scanf(&quot;%d&quot;, &amp;a);\n        sum += a;\n    }\n    printf(&quot;%d\\n&quot;, sum * 11 * (n - 1));\n    return 0;\n}<\/code><\/pre>\n<h4>1061 \u8f93\u5165\u65f6&amp;\u7b26\u3001\u4e8c\u7ef4\u6570\u7ec4\u6307\u9488<\/h4>\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\nusing namespace std;\n\nint main() {\n    int n, m, x, sum = 0;\n    scanf(&quot;%d%d&quot;, &amp;n, &amp;m);\n    int s[m], a[m], r[m];\n    for (int i = 0; i &lt; m; i++)\n        scanf(&quot;%d&quot;, s + i);\n\n    for (int i = 0; i &lt; m; i++)\n        scanf(&quot;%d&quot;, a + i);\n\n    for (int i = 0; i &lt; n; i++) {\n        for (int j = 0; j &lt; m; j++) {\n            scanf(&quot;%d&quot;, &amp;x);\n            if (x == a[j]) sum += s[j];\n        }\n        printf(&quot;%d\\n&quot;, sum);\n        sum = 0;\n    }\n    return 0;\n}<\/code><\/pre>\n<h4>1071 \u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7<\/h4>\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\nusing namespace std;\n\nint main()\n{\n    int t0, k, n1, b, t, n2;\n    scanf(&quot;%d%d&quot;, &amp;t0, &amp;k);\n    while (k--)\n    {\n        scanf(&quot;%d%d%d%d&quot;, &amp;n1, &amp;b, &amp;t, &amp;n2);\n        if (t0 &lt;= 0) { printf(&quot;Game Over.\\n&quot;); break; }\n        else if (t0 &lt; t) printf(&quot;Not enough tokens.  Total = %d.\\n&quot;, t0);\n        else if ((b == 0 &amp;&amp; n1 &gt; n2) || (b == 1 &amp;&amp; n1 &lt; n2)) { t0 += t; printf(&quot;Win %d!  Total = %d.\\n&quot;, t, t0); }\n        else { t0 -= t; printf(&quot;Lose %d.  Total = %d.\\n&quot;, t, t0); }\n    }\n    return 0;\n}<\/code><\/pre>\n<h4>1076 \u7a7a\u683c\u6362\u884c\u5904\u7406\u3001\u6ce8\u610f\u7d22\u5f15\u3001\u7b80\u5316\u63a7\u5236<\/h4>\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\nusing namespace std;\nint main() {\n    char s[4];\n    while (~scanf(&quot;%s&quot;, &amp;s))\n        if (s[2] == &#039;T&#039;)\n            printf(&quot;%d&quot;, s[0] - &#039;A&#039; + 1);\n    return 0;\n}<\/code><\/pre>\n<h4>1081 \u63a7\u5236\u7ed3\u6784\u3001getline<\/h4>\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\nusing namespace std;\n\nint main() {\n    bool nF, aF, qF;\n    string s;\n    getline(cin, s);\n    while(getline(cin, s)) {\n        nF = aF = qF =false;\n        if(s.length() &lt; 6) {\n            puts(&quot;Your password is tai duan le.&quot;);\n            continue;\n        }\n        for(int i = 0; s[i]; i++) {\n            if((s[i] &gt;= &#039;a&#039; &amp;&amp; s[i] &lt;= &#039;z&#039;) || (s[i] &gt;= &#039;A&#039; &amp;&amp; s[i] &lt;= &#039;Z&#039;))\n                aF = true;\n            else if(s[i] &gt;= &#039;0&#039; &amp;&amp; s[i] &lt;= &#039;9&#039;)\n                nF = true;\n            else if(s[i] != &#039;.&#039;) {\n                qF = true;\n                break;\n            }\n        }\n        if (qF)            puts(&quot;Your password is tai luan le.&quot;);\n        else if(aF &amp;&amp; nF)  puts(&quot;Your password is wan mei.&quot;);\n        else if(aF)        puts(&quot;Your password needs shu zi.&quot;);\n        else               puts(&quot;Your password needs zi mu.&quot;);\n    }\n    return 0;\n}<\/code><\/pre>\n<h4>1086 \u6ce8\u610f0\u7684\u5904\u7406<\/h4>\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\nusing namespace std;\n\nint main () {\n    int a, b;\n    scanf(&quot;%d%d&quot;, &amp;a, &amp;b);\n    a = a * b;\n    if(!a) { printf(&quot;0\\n&quot;); return 0; }\n    while(!(a % 10)) a \/= 10;\n    while(a) { printf(&quot;%d&quot;, a % 10); a \/= 10; }\n    printf(&quot;\\n&quot;);\n    return 0;\n}<\/code><\/pre>\n<h4>1091 \u4e0d\u540c\u7c7b\u578b\u4e4b\u95f4\u8fd0\u7b97\u8f6c\u6362<\/h4>\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\nusing namespace std;\n\nint main()\n{\n    int m, n;\n    long long k, l, s, t;\n    scanf(&quot;%d&quot;, &amp;m);\n    while (m--) {\n        scanf(&quot;%lld&quot;, &amp;k);\n        t = k;\n\n        for (s = 1; t; s *= 10)\n            t \/= 10;\n\n        for (n = 1; n &lt; 10; n++) {\n            l = n * k * k;\n            if (l % s == k) {\n                printf(&quot;%d %lld\\n&quot;, n, l);\n                break;\n            }\n        }\n        if (n == 10) printf(&quot;No\\n&quot;);\n    }\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6807\u9898\u6807\u660e\u6ce8\u610f\u70b9\u53ca\u76f8\u5173\u542f\u53d1 1001 \u7b80\u5355\u8ba1\u6570\u5668 #include&lt;iostream&gt; using  &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/139.196.114.170\/?p=1615\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cPAT- BASIC &#8211; 15POINTS\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/139.196.114.170\/index.php?rest_route=\/wp\/v2\/posts\/1615"}],"collection":[{"href":"http:\/\/139.196.114.170\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.196.114.170\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.196.114.170\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.196.114.170\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1615"}],"version-history":[{"count":34,"href":"http:\/\/139.196.114.170\/index.php?rest_route=\/wp\/v2\/posts\/1615\/revisions"}],"predecessor-version":[{"id":2734,"href":"http:\/\/139.196.114.170\/index.php?rest_route=\/wp\/v2\/posts\/1615\/revisions\/2734"}],"wp:attachment":[{"href":"http:\/\/139.196.114.170\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.196.114.170\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1615"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.196.114.170\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}