第二题题意是有n*m的方格,可以增加n、m的值,但不能减少。要求使得(n')*(m')>=6k,求n' * m' 的最小值,及此时的n' * m'
以为是很厉害的数论……当时比赛中没想出来……后来写个爆搜竟然A了……后悔莫及
就是从6k开始判断可行性,不行就一直+1+1……
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<ctime>
#define LL long long
using namespace std;
LL n,m,k;
bool rev;
inline LL read()
{
LL x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int main()
{
k=read();n=read();m=read();
if (n>m)swap(n,m),rev=1;
if (n*m>=6*k)
{
printf("%lld\n%lld %lld",n*m,n,m);
return 0;
}
k*=6;
while (1)
{
bool mrk=0;LL a=0;
for (int i=n;i<=sqrt(k);i++)
if (k%i==0&&k/i>=m)
{
mrk=1;
a=i;
break;
}
if (mrk)
{
if (!rev)printf("%lld\n%lld %lld",k,a,k/a);
else printf("%lld\n%lld %lld",k,k/a,a);
return 0;
}else k++;
}
}