题意RT:给定一个t问你有多少个<n,m>整数对使得n行m列的正方形个数=t
可以知道i行i列的正方形个数为i的平方前缀和,所以可以枚举n从1到t的^(1/3)(由平方前缀和公式可以推出n最大为该值),然后计算出对于n行固定的情况下每多一列,多了多少个正方形,得出等差数列为n*(n+1)(2n+1)/6+(n(n+1)/2)(m-n)=S(n,m),令S(n,m)=t,求出该n情况下的m,存储起来。
推导过程如下:
代码(没有测试平台,不知道正确性,欢迎指正):
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define G 6.67430*1e-11
#define rd read()
#define pi 3.1415926535
using namespace std;
const ll mod = 998244353;
inline ll read() {
ll x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch>'9') {
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
ll fpow(ll a, ll b)
{
ll ans = 1;
while (b)
{
if (b & 1)ans = ans * a % mod;
b >>= 1;
a = a * a % mod;
}
return ans;
}
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
const int N = 1000010;
bool isprime(int n)
{
for (int i = 2; i <= sqrt(n); i++)if (n % i == 0)return false;
return true;
}ll jc[300005];
ll C(int m, int n)
{
return jc[m] * fpow(jc[n], mod - 2) % mod * fpow(jc[m - n], mod - 2) % mod;
}
vector<int> m, w;
unordered_map<int, int> f,x,t,f1,f2;
int main()
{
ll t = rd;
ll i;
for (i = 1; i * i * i <= t||i*i*i<0; i++);
ll tmp = 2 * i;
vector<pll> v;
for (ll i = 1; i <= tmp; i++)
{
ll temp1 = (t - i * (i + 1) * (2*i + 1) / 6);
if (temp1 % (i * (i + 1) / 2) == 0)
{
ll j = (t - i * (i + 1) * (2 * i + 1) / 6) / (i * (i + 1) / 2) + i;
if (i > j)break;
v.push_back(mp(i, j));//cout << i<<' '<<j << endl;
if (i == j)break;
v.push_back(mp(j, i));
}
}
sort(v.begin(), v.end());
cout << v.size() << endl;
for (auto p : v)
{
cout << p.first << ' ' << p.second << endl;
}
return 0;
}
//cout << (97 * 4 + 95 + 95 * 3 + 88 + 88 * 4 + 87 * 3.5 + 80 * 0.25)/( 4 + 1 + 3 + 1 + 4 + 3.5 + 0.25 );