# 【CodeForces - 599D】Spongebob and Squares（推公式+枚舉）

Input

Output

Example

Input

```26
```

Output

```6
1 26
2 9
3 5
5 3
9 2
26 1
```

Input

`2`

ac代碼：

``````#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<vector>
#include<unordered_map>
#define mod (1000000007)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn=1e5+10;
struct node{
ll l,r;
}ans[2000000];
ll sum(ll x){ return (x+1)*x/2; }
ll sum2(ll x){ return x*(x+1)*(x+x+1)/6; }
int main(){
ll m,k,cnt=0;
scanf("%lld",&m);
for(ll k=1;;k++){
ll t1=(m-sum2(k-1)+sum(k-1)*k);
ll t2=(k*k-sum(k-1));
ll tmp=t1/t2;
if(tmp<k) break;
if(tmp*t2==t1){
ans[cnt].l=k;ans[cnt++].r=tmp;
}
}
printf("%d\n",cnt*2-(ans[cnt-1].l==ans[cnt-1].r));
for(int i=0;i<cnt;i++){
printf("%lld %lld\n",ans[i].l,ans[i].r);
}
if(ans[cnt-1].l!=ans[cnt-1].r) printf("%lld %lld\n",ans[cnt-1].r,ans[cnt-1].l);
for(int i=cnt-2;i>=0;i--)
printf("%lld %lld\n",ans[i].r,ans[i].l);
return 0;
}
//k
//k*k*n-sum(k-1)(k+n)+sum2(k-1)=m
//tmp=(m-sum2(k-1)+sum(k-1)*k)/(k*k-sum(k-1))另一個數
//
//k*n (k-1)*(n-1) (k-2)(n-2)
//k*n kn-k-n+1   kn-2k-2n+4
//1 n
//2 2*n+1
//3 4n-4``````