{"id":423,"date":"2018-08-09T13:02:26","date_gmt":"2018-08-09T13:02:26","guid":{"rendered":"https:\/\/www.haoyuan.info\/?p=423"},"modified":"2018-08-09T13:03:22","modified_gmt":"2018-08-09T13:03:22","slug":"wannafly-15-problem-a-%e7%9b%b4%e8%a7%92%e4%b8%89%e6%a3%b1%e9%94%a5","status":"publish","type":"post","link":"https:\/\/haoyuan.info\/?p=423","title":{"rendered":"Wannafly 15 Problem A \u76f4\u89d2\u4e09\u68f1\u9525"},"content":{"rendered":"<h2>\u9898\u89e3<\/h2>\n<p>\u9898\u76ee\u53ef\u4ee5\u8f6c\u5316\u4e3a\u63d2\u677f\u6cd5\u6c42\u89e3\u3002\u8003\u8651\u5f53$x + y + z &lt;= k$\u65f6\u6ee1\u8db3\u9898\u610f\uff0c\u5f15\u5165\u4e00\u4e2a$a$ \u53d8\u6210\u4e86$x + y + z + a = k$\u7136\u540e\u6211\u4eec\u9700\u8981\u6c42\u7684\u4fbf\u662f${k+3}\\choose{3}$\u3002<br \/>\n\u6ce8\u610f\u5230\u9898\u76ee\u7684\u6570\u636e\u8303\u56f4\uff0c\u53ef\u4ee5\u7528<code>__int128<\/code>\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n<h2>AC\u4ee3\u7801<\/h2>\n<pre><code class=\"language-cpp  line-numbers\">#include &lt;iostream&gt;\n#include &lt;cstring&gt;\n#include &lt;algorithm&gt;\n#include &lt;cstdlib&gt;\n#include &lt;array&gt;\n\nusing ll = long long;\nusing namespace std;\nusing lll = __int128;\n\nint main()\n{\n    ios::sync_with_stdio(false);\n    cin.tie(0);\n    cout.tie(0);\n    int T;\n    cin &gt;&gt; T;\n    while(T--)\n    {\n        ll k,m;\n        cin &gt;&gt; k &gt;&gt; m;\n        lll ans = k + 1;\n        cout &lt;&lt; (ll)(ans * (ans + 1) * (ans + 2) \/ 6 % m) &lt;&lt; \"\\n\";\n    }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u89e3 \u9898\u76ee\u53ef\u4ee5\u8f6c\u5316\u4e3a\u63d2\u677f\u6cd5\u6c42\u89e3\u3002\u8003\u8651\u5f53$x + y + z &lt;= k$\u65f6\u6ee1\u8db3\u9898\u610f\uff0c\u5f15\u5165\u4e00\u4e2a$a$ \u53d8\u6210\u4e86 [&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,44,56,22],"tags":[24,54],"class_list":["post-423","post","type-post","status-publish","format-standard","hentry","category-c","category-44","category-wannafly","category-22","tag-cpp","tag-54"],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8UC2c-6P","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/haoyuan.info\/index.php?rest_route=\/wp\/v2\/posts\/423","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=423"}],"version-history":[{"count":0,"href":"https:\/\/haoyuan.info\/index.php?rest_route=\/wp\/v2\/posts\/423\/revisions"}],"wp:attachment":[{"href":"https:\/\/haoyuan.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haoyuan.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haoyuan.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}