据题意:
$K=\sum\limits_{i=0}^{n-1}(n-i)*(m-i)$
$K=n^2m-(n+m)\sum{i}+\sum{i^2}$
展开化简
$m=(6k-n+n^3)/(3n^2+3n)$
枚举n,验证整除,只做n<=m,其余反过来输出即可
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <vector> using namespace std; vector<pair<long long,long long> >S; int main()
{
long long x,i,Ans=; scanf("%lld",&x);
for(i=;;++i)
{
long long n=i,m=(6LL*x-n+n*n*n)/(*n*n+*n);
if(n>m)break;
if((6LL*x-n+n*n*n)%(*n*n+*n)==)
{
S.push_back(make_pair(n,m));
}
}
if(S.back().first==S.back().second)
{
Ans=-;
}
Ans+=(int)S.size()<<; printf("%lld\n",Ans);
for(i=;i<(int)S.size();++i)
{
printf("%lld %lld\n",S[i].first,S[i].second);
} if(S.back().first==S.back().second)
{
S.pop_back();
} while(!S.empty())
{
printf("%lld %lld\n",S.back().second,S.back().first);
S.pop_back();
}
return ;
}