正文
增加 13 行删除 16 行
1234567891011121314151644 行未改动616263646566676869707172737475767778798081828347 行未改动# 这题怎么做?找规律,先打表,看有什么规律。# 打表暴力,注意:**只打到 $8 \times 8$**,太大了容易溢出。**不要取模**,不然可能看不出规律。**不要对样例找规律**,我一开始找了个 $ans=n^2m$。打表。```#include <bits/stdc++.h>using namespace std;44 行未改动```得到了 $\div 2$ 后的数据:```0 1 3 6 10 15 21 280 1 6 18 40 75 126 1960 1 12 54 160 375 756 13720 1 24 162 640 1875 4536 96040 1 48 486 2560 9375 27216 672280 1 96 1458 10240 46875 163296 4705960 1 192 4374 40960 234375 979776 3294172```发现,第一行($n=2$)满足 $ans_{2,j}=j \times( j-1) \times 0.5$,而当 $n>2$ 时,满足 $ans_{n,j}=ans_{n-1,j}\times (j-1)$,即有 $ans_{n,j}=(j-1)^{n-2} \times j \times (j-1) \div 2=(j-1)^{n-1} \times j\div 2$,**这是 $\div 2$ 后的,记得乘 $2$**。$ans_{n,j}=(j-1)^{n-1}*j$。# code***不要对指数取模***。```#include <bits/stdc++.h>#define int long long//开longlongusing namespace std;47 行未改动123456789101112131415161718192044 行未改动6566676869707172737475767778798047 行未改动好像没有找规律的题解,找规律也是一种做题的办法。# 这题怎么做?找规律,先打表,看有什么规律。# 找规律注意:只打到 $8 \times 8$,太大了容易溢出。**不要取模**,不然可能看不出规律。不要对样例找规律,我一开始找了个 $ans=n^2 \times m$。打表。```#include <bits/stdc++.h>using namespace std;44 行未改动```得到了 $\div 2$ 后的数据:发现,第一行($n=2$)满足 $ans_{2,j}=j \times( j-1) \times 0.5$,而当 $n>2$ 时,满足 $ans_{n,j}=ans_{n-1,j}\times (j-1)$,即有 $ans_{n,j}=(j-1)^{n-2} \times j \times (j-1) \div 2=(j-1)^{n-1} \times j\div 2$,这是 $\div 2$ 后的,**记得乘 $2$**。$ans_{n,j}=(j-1)^{n-1}\times j$。# code*不要对指数取模*。```#include <bits/stdc++.h>#define int long long//开longlongusing namespace std;47 行未改动