返回题解分享
讨论 / 题解分享/ 帖子详情

货物摆放(结果填空) - 题解

不能用三重暴力循环,会超时,要用剪枝然后进行判断

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn=2021041820210418;

ll a,b,c,ans;

bool check(int x)

{


if(maxn%x==0)return true;

else return false;

}

bool check2()

{


if(maxn%(a\b)==0)return true;

else return false;

}

int main()

{


//ios::sync_with_stdio(false),cout.tie(0),cin.tie(0);

for(a=1;a\
a\*a<=maxn;a++)

{

if(check(a))

{

	for(b=a;a\*b\*b<=maxn;b++)

	{

		if(check2())

		{

			c=maxn/(a\*b);

			printf("%lld %lld %lld\\n",a,b,c);

			if(a==b&&a==c)ans+=1;

			else if(a==b||a==c||b==c)ans+=3;

			else ans+=6;

		}

	}

}


}

cout<<ans;

return 0;

}
0 回复 0 转发 0 喜欢 0 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!