{"id":516,"date":"2020-05-15T23:00:24","date_gmt":"2020-05-15T15:00:24","guid":{"rendered":"http:\/\/www.zyhcoding.club\/?p=516"},"modified":"2020-05-15T23:42:00","modified_gmt":"2020-05-15T15:42:00","slug":"%e5%b0%8fv%e5%92%8c%e6%96%b9%e7%a8%8b-%e5%94%af%e4%b8%80%e5%88%86%e8%a7%a3%e5%ae%9a%e7%90%86%e6%95%b4%e6%95%b0%e5%88%92%e5%88%86","status":"publish","type":"post","link":"http:\/\/www.zyhcoding.club\/index.php\/2020\/05\/15\/%e5%b0%8fv%e5%92%8c%e6%96%b9%e7%a8%8b-%e5%94%af%e4%b8%80%e5%88%86%e8%a7%a3%e5%ae%9a%e7%90%86%e6%95%b4%e6%95%b0%e5%88%92%e5%88%86\/","title":{"rendered":"\u5c0fV\u548c\u65b9\u7a0b  \u552f\u4e00\u5206\u89e3\u5b9a\u7406+\u6574\u6570\u5212\u5206"},"content":{"rendered":"<h4><a href=\"https:\/\/ac.nowcoder.com\/acm\/contest\/5555\/A\">\u5c0fV\u548c\u65b9\u7a0b<\/a><\/h4>\n<p>\u9898\u76ee\u5c31\u770b\u9898\u53bb\u5427\uff0c\uff0c<\/p>\n<p>\u8bc1\u660e\uff1a\u8bbei,j,k\u4e3a\u5355\u8d28\u6570\u4e4b\u79ef(\u5373\u6bcf\u4e2a\u8d28\u6570\u6700\u591a\u88ab\u4e581\u6b21)\uff0ci,j,k\u7684\u503c\u4e0d\u540c\uff0c<code class=\"katex-inline\">a\\sqrt{i}+b\\sqrt{j}=c\\sqrt{m}<\/code>\u65e0\u89e3\u3002<br \/>\n\u7cfb\u6570a\uff0cb\uff0cc\u4efb\u610f\u3002\u4e24\u8fb9\u5206\u522b\u5e73\u65b9\uff0c\u5b8c\u540e\u5f0f\u5b50\u53f3\u8fb9\u662f\u4e00\u4e2a\u6574\u6570\uff0c\u5de6\u8fb9\u4f1a\u6709\u4e00\u9879<code class=\"katex-inline\">\\sqrt{ij}<\/code>\uff0c\u7cfb\u6570\u4e0d\u91cd\u8981\uff0c\u8fd9\u4e00\u9879\u662f\u5f00\u4e0d\u51fa\u6765\u7684\uff0c\u4e00\u5b9a\u662f\u5c0f\u6570\uff0c\u4e0d\u53ef\u80fd\u5f00\u51fa\u4e00\u4e2a\u6574\u6570\u6765\uff0c\u56e0\u4e3aij\u662f\u4e00\u4e9b\u4e0d\u540c\u8d28\u6570\u7684\u79ef\u3002<\/p>\n<pre><code>\u518d\u56de\u5230\u8fd9\u9898\uff0c\u6211\u4eec\u628am\u8d28\u56e0\u6570\u5206\u89e3\uff0c\u6839\u53f7\u5185\u4e3a\u4e00\u5355\u8d28\u6570\u4e4b\u79ef\uff0c\u6839\u53f7\u5916\u4e3a\u7cfb\u6570a\u3002\u628a\u7b49\u5f0f\u5de6\u8fb9\u7684\u6bcf\u4e00\u9879\u4e5f\u90fd\u8fd9\u6837\u8868\u793a\uff0c\u90a3\u4e48\u5de6\u8fb9\u7684\u9879\u4e2d\uff0c\u6839\u53f7\u5185\u7684\u6570\u8981\u4e48\u548c\u53f3\u8fb9\u6839\u53f7\u5185\u7684\u6570\u76f8\u540c\uff0c\u8981\u4e48\u5c31\u662f0.\n\n\u90a3\u4e48\u95ee\u9898\u8f6c\u5316\u6210\uff0c\u628a\u53f3\u8fb9\u7684\u7cfb\u6570a\u5206\u89e3\u6210n\u4e2a\u6570\u3002\u56e0\u4e3a\u53ef\u80fd\u67090\u7684\u60c5\u51b5\uff0c\u6211\u4eec\u628a\u975e0\u7684\u9879\u5f53\u6210\u6709\u6548\u9879\uff0c\u90a3\u4e48\u6709\u6548\u9879\u7684\u4e2a\u6570\u53ef\u4ee5\u4e3a1-n\u3002\n\n\u95ee\u9898\u8fdb\u4e00\u6b65\u8f6c\u5316\u6210\u4e3a\u628aa\u5206\u89e3\u6210i\u4e2a\u975e0\u6570\uff0c\u6c42\u6709\u591a\u5c11\u79cd\u5206\u89e3\u65b9\u6848\uff0c\u6bcf\u4e24\u79cd\u65b9\u6848\u6570\u5b57\u91cd\u7ec4\u540e\u4e0d\u80fd\u76f8\u540c\u3002\u5373\u6574\u6570\u5212\u5206\u3002<\/code><\/pre>\n<p>\u6574\u6570\u5212\u5206\uff0c\u6c42\u628an\u5206\u89e3\u6210k\u4e2a\u975e0\u6570\u7684\u65b9\u6848\u4e2a\u6570\u3002\u8bbedp[n][k]\u8868\u793a\u8fd9\u4e00\u503c\u3002\u6709\u65b9\u7a0b\uff1a<br \/>\n<code class=\"katex-inline\">dp[i][j] = dp[i-j][j] + dp[i-1][j-1]<\/code><br \/>\n\u9996\u5148\u6211\u4eec\u53ef\u4ee5\u7406\u89e3\uff0c\u628ai\u4e2a\u7269\u54c1\u653e\u5728j\u4e2a\u5bb9\u5668\u5185\uff0c\u56e0\u4e3a\u8981\u6c42\u975e\u7a7a\uff0c\u9996\u5148\u6bcf\u4e2a\u5bb9\u5668\u5185\u653e1\u4e2a\uff0c\u7136\u540e\u5269\u4e0bi-j\u4e2a\u7269\u54c1\u53ef\u4ee5\u653e\u8fdb1\u4e2a\uff0c2\u4e2a\uff0c\uff0c\uff0cj\u4e2a\u5bb9\u5668\u5185\uff0c\u6bcf\u4e00\u79cd\u653e\u6cd5\u90fd\u662f\u4e92\u4e0d\u76f8\u540c\u7684\u3002<br \/>\n<code class=\"katex-inline\">dp[i][j] = dp[i-j][1] + dp[i-j][2] + ... + dp[i-j][j]<\/code><br \/>\n\u5316\u7b80<br \/>\n<code class=\"katex-inline\">dp[i][j] = dp[i-j][1] + dp[i-j][2] + ... + dp[i-j][j]<\/code><br \/>\n<code class=\"katex-inline\">= dp[(i-1)-(j-1)][1] + dp[(i-1)-(j-1)][2] + ... + dp[(i-1)-(j-1)][j-1] + dp[i-j][j]<\/code><br \/>\n<code class=\"katex-inline\">= dp[i-1][j-1] + dp[i-j][j]<\/code><\/p>\n<pre><code class=\"language-c++\">void init(int n, int k){\n    for(int i=1;i&lt;=n;i++)\n        dp[i][1]=1;\n    for(int i=1;i&lt;=n;i++)\n        for(int j=2;j&lt;=k;j++)    if(i&gt;=j)\n            dp[i][j] = dp[i-j][j]+dp[i-1][j-1];\n    return;\n}<\/code><\/pre>\n<p>\u672c\u9898AC\u4ee3\u7801<\/p>\n<pre><code class=\"language-c++\">#include &lt;cstdio&gt;\n#include &lt;cmath&gt;\nusing namespace std;\ntypedef long long ll;\nconst ll mod = 998244353;\nll dp[1005][1005];            \/\/dp[i][j]\uff0ci\u5206\u89e3\u6210j\u4e2a\u6570\nint n, m, a;\ninline void init(int n, int k){\n    for(int i=1;i&lt;=n;i++)\n        dp[i][1]=1;\n    for(int i=1;i&lt;=n;i++)\n        for(int j=2;j&lt;=k;j++)    if(i&gt;=j)\n            dp[i][j] = (dp[i-j][j]+dp[i-1][j-1])%mod;\n    return;\n}\ninline int GetA(int m){\n    int tmp = m, ans = 1;\n    for (int i=2;i*i&lt;=m;i++){\n        if (tmp%i)  continue;\n        int t = 0;\n        while (tmp%i==0){\n            t++;\n            tmp \/= i;\n        }\n        ans *= pow(i, t\/2);\n    }\n    return ans;\n}\nint main(){\n    scanf (&quot;%d %d&quot;, &amp;n, &amp;m);\n    a = GetA(m);\n    ll ans = 0;\n    init(a, n);\n    for (int i=1;i&lt;=n;i++)  if (a&gt;=i)\n        ans = (ans+dp[a][i])%mod;\n    printf (&quot;%lld&quot;, ans);\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5c0fV\u548c\u65b9\u7a0b \u9898\u76ee\u5c31\u770b\u9898\u53bb\u5427\uff0c\uff0c \u8bc1\u660e\uff1a\u8bbei,j,k\u4e3a\u5355\u8d28\u6570\u4e4b\u79ef(\u5373\u6bcf\u4e2a\u8d28\u6570\u6700\u591a\u88ab\u4e581\u6b21)\uff0ci,j,k [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[],"_links":{"self":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts\/516"}],"collection":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/comments?post=516"}],"version-history":[{"count":15,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts\/516\/revisions"}],"predecessor-version":[{"id":520,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts\/516\/revisions\/520"}],"wp:attachment":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/media?parent=516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/categories?post=516"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/tags?post=516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}