Rn_Lamsuly @ 2020-05-24 20:28:29
#include<bits/stdc++.h>
using namespace std;
inline int read(){
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
int main()
{
int n;
int a=-1,b=-1,c=-1;
n=read();
if(n==0){
cout<<0<<' '<<0<<' '<<0;
return 0;
}
if(n<3){
cout<<-1;
return 0;
}
if(n%14==0){
cout<<n/14<<' '<<n/14<<' '<<n/14;
return 0;
}
for(register int i=0;i*7<=n;i++)
{
for(register int j=0;j<=(n-7*i)/4;j++)
{
for(register int k=0;k<=(n-((n-7*i)/4))/3;k++)
{
if(7*i+j*4+3*k!=n)continue;
if(min(i,min(j,k))>min(a,min(b,c)))
{
a=i;
b=j;
c=k;
}
if(i+j+k>a+b+c&&min(i,min(j,k))==min(a,min(b,c)))
{
a=i;
b=j;
c=k;
}
}
}
}
if(a==-1&&b==-1&&c==-1)cout<<-1;
else cout<<a<<' '<<b<<' '<<c;
return 0;
}
by Malody @ 2020-05-24 20:29:06
没极限呢……
by xhQYm @ 2020-05-24 20:29:37
你这算法肯定 TLE 啊
by Malody @ 2020-05-24 20:29:38
离极限还很远
by Malody @ 2020-05-24 20:30:08
建议你不要卡常了,想想双重循环、不用循环的做法
by KevTheDev @ 2020-05-24 20:33:09
厌氧
by critnos @ 2020-05-24 20:35:44
@肾小囊190350 我认为您的代码并没有极限卡常,,下面判断还是常数太大
by JohnVictor @ 2020-05-24 20:36:08
卡常还不四层展开差评
by Graphcity @ 2020-05-24 20:49:25
@肾小囊190350 如果你真的想要极限卡常的话...
by Na2PtCl6 @ 2020-05-24 21:51:22
快读要改成
inline int getint(){
char c=getchar();int a=0;
for(;c<'0'||c>'9';c=getchar());
for(;c>='0'&&c<='9';c=getchar())
a=(a<<1)+(a<<3)+(c^48);
return a;
}
by Na2PtCl6 @ 2020-05-24 21:51:33
@肾小囊190350