Codeforces Round #332 (Div. 2)D. Spongebob and Squares(数学方程,暴力)

原创 2015年11月21日 15:34:45

题目链接
题意:给你一个数X问,n*m的矩形中,面积不同的正方形的个数和是X。输出所有的 n * m
解法:这里写图片描述
然后继续化简是6*x+n^3-n=(3 * n^2+3 * n) * m是关于m的函数,我们直接枚举n,就好了,注意上限,


#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define X first
#define Y second
#define cl(a,b) memset(a,b,sizeof(a))
typedef pair<long long ,long long > P;
const int maxn=100005;
const LL inf=1LL<<45;
const LL mod=1e9+7;
vector<P> ans;
int main(){
    LL x;scanf("%lld",&x);
    ans.pb(P(1,x/1));
    bool same=false;
    if(1==x/1)same=true;
    for(LL n=2;n<=10000000||n*n*n<=x;n++){
        LL a=6*x+n*n*n-n;
        LL b=3*n*n+3*n;
        if(a%b==0){
            if(n==a/b)same=true;
            if(n<=a/b)ans.pb(P(n,a/b));
        }
    }

    int N=2*ans.size();
    if(same)N-=1;
    printf("%d\n",N);
    for(int i=0;i<ans.size();i++){
        printf("%lld %lld\n",ans[i].X,ans[i].Y);
    }
     for(int i=ans.size()-1;i>=0;i--){
        if(ans[i].X!=ans[i].Y)printf("%lld %lld\n",ans[i].Y,ans[i].X);
    }
    return 0;
}


版权声明:一个菜逼的笔记,并没有什么题解。。。

【Codeforces Round 332 (Div 2)D】【数学 公式推导】Spongebob and Squares 正方形数量恰好为x个的所有大矩形

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

Codeforces Round #332 (Div. 2) D. Spongebob and Squares

Spongebob is already tired trying to reason his weird actions and calculations, so he simply asked y...

Codeforces Round #332 (Div. 2) D. Spongebob and Squares详解

Codeforces Round #332 (Div. 2) D. Spongebob and Squares

Codeforces Round #332 (Div. 2) B. Spongebob and Joke

Codeforces Round #332 (Div. 2) C. Spongebob and Joke Vector

Codeforces Round #332 (Div. 2)_B. Spongebob and Joke

B. Spongebob and Joke time limit per test 2 seconds memory limit per test 256 megabytes ...

【Codeforces Round 332 (Div 2)B】【扭转题意 位置映射】Spongebob and Joke 给b[]中的每个数找f[]中的位置

B. Spongebob and Joke time limit per test 2 seconds memory limit per test 256 megabytes ...

Codeforces Round #177 (Div. 2)---D. Polo the Penguin and Houses (组合数学+暴力)

Little penguin Polo loves his home village. The village has n houses, indexed by integers from 1 to ...

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

D. Spongebob and Squares time limit per test 2 seconds memory limit per test 256 megabyt...
  • Bcwan_
  • Bcwan_
  • 2016年08月30日 20:26
  • 284

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

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

Coderforce #332 D. Spongebob and Squares

题意 给你x,然后让你找有多少个n*m的矩形,可以由x个相同的多边形组成 题解: 数学题,这道题实际上是问,f(n,m) = sigma(k=1,k=min(n,m))(n-k+1)...
  • Ezereal
  • Ezereal
  • 2015年11月24日 23:01
  • 232
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Codeforces Round #332 (Div. 2)D. Spongebob and Squares(数学方程,暴力)
举报原因:
原因补充:

(最多只允许输入30个字)