{"id":381,"date":"2018-08-04T15:12:21","date_gmt":"2018-08-04T15:12:21","guid":{"rendered":"https:\/\/www.haoyuan.info\/?p=381"},"modified":"2018-09-24T08:03:30","modified_gmt":"2018-09-24T08:03:30","slug":"%e8%be%93%e5%85%a5%e8%be%93%e5%87%ba%e6%8c%82%e5%a4%87%e4%bb%bd","status":"publish","type":"post","link":"https:\/\/haoyuan.info\/?p=381","title":{"rendered":"\u8f93\u5165\u8f93\u51fa\u6302\u5907\u4efd"},"content":{"rendered":"<p>\u5907\u4efd\u4e00\u4e0b\u81ea\u5df1\u7684\u8f93\u5165\u8f93\u51fa\u6302<br \/>\n\u8f93\u5165\u8f93\u51fa\u6570\u636e\u91cf\u7279\u522b\u5927\u7684\u65f6\u5019\u6548\u679c\u62d4\u7fa4<br \/>\n\u4f7f\u7528\u65b9\u6cd5:<\/p>\n<pre><code class=\"language-cpp line-numbers\">int a;\nlong long b;\nchar c;\nstring d;\nchar str[100];\nfin &gt;&gt; a &gt;&gt; b &gt;&gt; c &gt;&gt; d &gt;&gt; str &lt;&lt; a &lt;&lt; b &lt;&lt; c &lt;&lt; d &lt;&lt; str;(wwww)\n<\/code><\/pre>\n<pre><code class=\"language-cpp line-numbers\">#include &lt;iostream&gt;\n#include &lt;cstdio&gt;\n#include &lt;cstring&gt;\n#include &lt;list&gt;\n#include &lt;cmath&gt;\n#include &lt;algorithm&gt;\n#include &lt;vector&gt;\n#include &lt;map&gt;\n#include &lt;queue&gt;\n#include &lt;stack&gt;\n#include &lt;set&gt;\n#include &lt;complex&gt;\n#define ONLINE_JUDGE\nusing ll = long long;\n\/*\n * \u8f93\u5165\u6302\n * \u573a\u573aAK buff\n *\/\nnamespace IO {\n    using namespace std;\n    class endln {\n    };\n\n    class iofstream {\n    private:\n        int idx;\n        bool eof;\n        char buf[100005], *ps, *pe;\n        char bufout[100005], outtmp[50], *pout, *pend;\n\n        inline void rnext() {\n            if (++ps == pe)\n                pe = (ps = buf) + fread(buf, sizeof(char), sizeof(buf) \/ sizeof(char), stdin), eof = true;\n            \/\/eof = ps != pe;\n        }\n\n        inline void write() {\n            fwrite(bufout, sizeof(char), pout - bufout, stdout);\n            pout = bufout;\n        }\n\n    public:\n        iofstream() : idx(-1), eof(true) {\n            pe = (ps = buf) + 1;\n            pend = (pout = bufout) + 100005;\n        }\n\n        ~iofstream() {\n            write();\n        }\n\n        template&lt;class T&gt;\n        inline bool fin(T &amp;ans) {\n#ifdef ONLINE_JUDGE\n            ans = 0;\n            T f = 1;\n            if (ps == pe) {\n                return eof = false;\n            }\n            do {\n                rnext();\n                if ('-' == *ps) f = -1;\n            } while (!isdigit(*ps) &amp;&amp; ps != pe);\n            if (ps == pe) {\n                return eof = false;\n            }\n            do {\n                ans = (ans &lt;&lt; 1) + (ans &lt;&lt; 3) + *ps - 48;\n                rnext();\n            } while (isdigit(*ps) &amp;&amp; ps != pe);\n            ans *= f;\n#else\n            cin &gt;&gt; ans;\n#endif\n            return true;\n        }\n\n        template&lt;class T&gt;\n        inline bool fdb(T &amp;ans) {\n#ifdef ONLINE_JUDGE\n            ans = 0;\n            T f = 1;\n            if (ps == pe) return false;\/\/EOF\n            do {\n                rnext();\n                if ('-' == *ps) f = -1;\n            } while (!isdigit(*ps) &amp;&amp; ps != pe);\n            if (ps == pe) return false;\/\/EOF\n            do {\n                ans = ans * 10 + *ps - 48;\n                rnext();\n            } while (isdigit(*ps) &amp;&amp; ps != pe);\n            ans *= f;\n            if (*ps == '.') {\n                rnext();\n                T small = 0;\n                do {\n                    small = small * 10 + *ps - 48;\n                    rnext();\n                } while (isdigit(*ps) &amp;&amp; ps != pe);\n                while (small &gt;= 1) {\n                    small \/= 10;\n                }\n                ans += small;\n            }\n#else\n            cin &gt;&gt; ans;\n#endif\n            return true;\n        }\n\n\/*\n * \u8f93\u51fa\u6302\n * \u8d85\u5f3a \u8d85\u5feb\n *\/\n\n        inline bool out_char(const char c) {\n#ifdef ONLINE_JUDGE\n            *(pout++) = c;\n            if (pout == pend) write();\n#else\n            cout &lt;&lt; c;\n#endif\n            return true;\n        }\n\n        inline bool out_str(const char *s) {\n#ifdef ONLINE_JUDGE\n            while (*s) {\n                *(pout++) = *(s++);\n                if (pout == pend) write();\n            }\n#else\n            cout &lt;&lt; s;\n#endif\n            return true;\n        }\n\n        template&lt;class T&gt;\n        inline bool out_double(T x, int idx) {\n            char str[50];\n            string format = \"%\";\n            if (~idx) {\n                format += '.';\n                format += (char) (idx + '0');\n            }\n            format += \"f\";\n            sprintf(str, format.c_str(), x);\n            out_str(str);\n            return true;\n        }\n\n        template&lt;class T&gt;\n        inline bool out_int(T x) {\n#ifdef ONLINE_JUDGE\n            if (!x) {\n                out_char('0');\n                return true;\n            }\n            if (x &lt; 0) x = -x, out_char('-');\n            int len = 0;\n            while (x) {\n                outtmp[len++] = x % 10 + 48;\n                x \/= 10;\n            }\n            outtmp[len] = 0;\n            for (int i = 0, j = len - 1; i &lt; j; ++i, --j) swap(outtmp[i], outtmp[j]);\n            out_str(outtmp);\n#else\n            cout &lt;&lt; x;\n#endif\n            return true;\n        }\n\n\n        inline iofstream &amp;operator&lt;&lt;(const double &amp;x) {\n            out_double(x, idx);\n            return *this;\n        }\n\n        inline iofstream &amp;operator&lt;&lt;(const int &amp;x) {\n            out_int(x);\n            return *this;\n        }\n\n        inline iofstream &amp;operator&lt;&lt;(const unsigned long long &amp;x) {\n            out_int(x);\n            return *this;\n        }\n\n        inline iofstream &amp;operator&lt;&lt;(const unsigned &amp;x) {\n            out_int(x);\n            return *this;\n        }\n\n        inline iofstream &amp;operator&lt;&lt;(const long &amp;x) {\n            out_int(x);\n            return *this;\n        }\n\n        inline iofstream &amp;operator&lt;&lt;(const ll &amp;x) {\n            out_int(x);\n            return *this;\n        }\n\n        inline iofstream &amp;operator&lt;&lt;(const endln &amp;x) {\n            out_char('\\n');\n            return *this;\n        }\n\n\n        inline iofstream &amp;operator&lt;&lt;(const char *x) {\n            out_str(x);\n            return *this;\n        }\n\n        inline iofstream &amp;operator&lt;&lt;(const string &amp;x) {\n            out_str(x.c_str());\n            return *this;\n        }\n\n        inline iofstream &amp;operator&lt;&lt;(const char &amp;x) {\n            out_char(x);\n            return *this;\n        }\n\n        inline bool setw(int x) {\n            if (x &gt;= 0) {\n                idx = x;\n                return true;\n            }\n            return false;\n        }\n\n        inline iofstream &amp;operator&gt;&gt;(int &amp;x) {\n            if (!fin(x) &amp;&amp; !x)eof = false;\n            return *this;\n        }\n\n        inline iofstream &amp;operator&gt;&gt;(ll &amp;x) {\n            if (!fin(x) &amp;&amp; !x)eof = false;\n            return *this;\n        }\n\n        inline iofstream &amp;operator&gt;&gt;(double &amp;x) {\n            if (!fdb(x) &amp;&amp; x == 0.0)eof = false;\n            return *this;\n        }\n\n        inline iofstream &amp;operator&gt;&gt;(float &amp;x) {\n            if (!fdb(x) &amp;&amp; x == 0.0)eof = false;\n            return *this;\n        }\n\n        inline iofstream &amp;operator&gt;&gt;(unsigned &amp;x) {\n            if (!fin(x) &amp;&amp; !x)eof = false;\n            return *this;\n        }\n\n        inline iofstream &amp;operator&gt;&gt;(unsigned long long &amp;x) {\n            if (!fin(x) &amp;&amp; !x)eof = false;\n            return *this;\n        }\n\n        inline explicit operator bool() {\n            return eof;\n        }\n\n        inline char getchar() {\n#ifdef ONLINE_JUDGE\n            if (ps == pe) {\n                return eof = false;\n            }\n            rnext();\n            if (ps + 1 == pe)\n                eof = false;\n            return *ps;\n#else\n            return std::getchar();\n#endif\n        }\n\n        inline iofstream &amp;operator&gt;&gt;(char *str) {\n#ifdef ONLINE_JUDGE\n            if (ps == pe) {\n                eof = false;\/\/EOF\n                return *this;\n            }\n            do {\n                rnext();\n            } while (isspace(*ps) &amp;&amp; iscntrl(*ps) &amp;&amp; ps != pe);\n            if (ps == pe) {\n                eof = false;\/\/EOF\n                return *this;\n            }\n            do {\n                *str = *ps;\n                ++str;\n                rnext();\n            } while (!(isspace(*ps) || iscntrl(*ps)) &amp;&amp; ps != pe);\n            *str = '\\0';\n            return *this;\n#else\n            cin &gt;&gt; str;\n            return *this;\n#endif\n        }\n\n        inline iofstream &amp;operator&gt;&gt;(string &amp;str) {\n#ifdef ONLINE_JUDGE\n            str.clear();\n            if (ps == pe) {\n                eof = false;\/\/EOF\n                return *this;\n            }\n            do {\n                rnext();\n            } while (isspace(*ps) &amp;&amp; iscntrl(*ps) &amp;&amp; ps != pe);\n            if (ps == pe) {\n                eof = false;\/\/EOF\n                return *this;\n            }\n            do {\n                str += *ps;\n                rnext();\n            } while (!(isspace(*ps) || iscntrl(*ps)) &amp;&amp; ps != pe);\n            return *this;\n#else\n            cin &gt;&gt; str;\n            return *this;\n#endif\n        }\n    };\n\n    static iofstream fin;\n    static endln ln;\n}\nusing IO::fin;\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5907\u4efd\u4e00\u4e0b\u81ea\u5df1\u7684\u8f93\u5165\u8f93\u51fa\u6302 \u8f93\u5165\u8f93\u51fa\u6570\u636e\u91cf\u7279\u522b\u5927\u7684\u65f6\u5019\u6548\u679c\u62d4\u7fa4 \u4f7f\u7528\u65b9\u6cd5: int a; long long b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[39,40],"tags":[],"class_list":["post-381","post","type-post","status-publish","format-standard","hentry","category-c","category-40"],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8UC2c-69","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/haoyuan.info\/index.php?rest_route=\/wp\/v2\/posts\/381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/haoyuan.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/haoyuan.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/haoyuan.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/haoyuan.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=381"}],"version-history":[{"count":4,"href":"https:\/\/haoyuan.info\/index.php?rest_route=\/wp\/v2\/posts\/381\/revisions"}],"predecessor-version":[{"id":446,"href":"https:\/\/haoyuan.info\/index.php?rest_route=\/wp\/v2\/posts\/381\/revisions\/446"}],"wp:attachment":[{"href":"https:\/\/haoyuan.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haoyuan.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haoyuan.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}