# CF 599D 思维

Codeforces 559D

http://codeforces.com/problemset/problem/599/D

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <vector>
using namespace std;
#define LL long long
const int MAXN = 1e6 + 5;
struct D
{
LL u, v;
}ans[MAXN];
LL cal3(LL a)
{
return a * (a + 1) * (2 * a + 1) / 6;
}
bool cmp(D a, D b){return a.u < b.u;}
int main()
{
LL a;
while(scanf("%I64d", &a) != EOF){
int cnt = 0;
for(LL i = 1 ; cal3(i) <= a ; i++){
LL rest = a - cal3(i);
LL d = (i + 1) * i / 2;
if(rest % d == 0){
//                 printf("cal3(i) = %I64d\n", cal3(i));
//                printf("i = %I64d, rest = %I64d, d = %I64d\n", i, rest, d);
ans[cnt].u = i, ans[cnt++].v = i + rest / d;
if(rest != 0)   ans[cnt].u = i + rest / d, ans[cnt++].v = i;
}
}
sort(ans, ans + cnt, cmp);
printf("%d\n", cnt);
for(int i = 0 ; i < cnt ; i++)
printf("%I64d %I64d\n", ans[i].u, ans[i].v);
}
return 0;
}

• 本文已收录于以下专栏：

## Codeforces 599D Spongebob and Squares【思维枚举+数学方程】

D. Spongebob and Squares time limit per test 2 seconds memory limit per test 256 megabytes ...

## CF - 519D. A and B and Interesting Substrings - 前缀和思维+map

1.题目描述： D. A and B and Interesting Substrings time limit per test 2 seconds memory l...

## CF Round #423 Div. 2 C. String Reconstruction D. High Load 【思维】

CF Round #423 Div. 2 C. String Reconstruction D. High Load 【思维】 Ivan had string s consisting of ...

## CF - 805D. Minimum number of steps - 思维+快速幂

1.题目描述： D. Minimum number of steps time limit per test 1 second memory limit per test 256 mega...

## Codeforces 463D Gargari and Permutations【思维建图+Floyd跑最长路】不愧是CF的评测姬

D. Gargari and Permutations time limit per test 2 seconds memory limit per test 256 megabyte...

## CF - 808D. Array Division - 二分+暴力+前缀和思维

1.题目描述： D. Array Division time limit per test 2 seconds memory limit per test 256 m...

## CF - 782D. Innokenty and a Football League - 模拟+思维+贪心+dfs插入

1.题目描述： D. Innokenty and a Football League time limit per test 2 seconds m...

## CodeForces 599D Spongebob and Squares(DP＋math)

Spongebob and Squares Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u...

## codeforces 599D. Spongebob and Squares【推公式+暴力枚举】

D. Spongebob and Squares time limit per test 2 seconds memory limit per test 256 megabyt...

举报原因： 您举报文章：深度学习：神经网络中的前向传播和反向传播算法推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)