zbw666 @ 2020-03-10 16:31:48
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
cin>>n;
if(n==0){
cout<<"0 0 0"<<endl;
return 0;
}
if(n<14){
if(n<=2 || n==5){
cout<<-1;
return 0;
}
if(n%3==0){
cout<<0<<" "<<0<<" "<<n/3;
}
else if(n%3==1){
cout<<0<<" "<<1<<" "<<n/3-1;
}
else{
cout<<0<<" "<<2<<" "<<n/3-2;
}
return 0;
}
if(n%14==0){
cout<<n/14<<" "<<n/14<<" "<<n/14;
return 0;
}
else{
int a=n/3,b=0,c=0;
if(n%3==1)
a--,b++;
else if(n%3==2)
a-=2,b+=2;
for(;;){
if(a>b){
a-=4;
b+=3;
}
else{
a+=4;
b-=3;
break;
}
}
for(;;){
if(c>b){
c--,b++,a++;
break;
}
c++,b--,a--;
}
cout<<c<<" "<<b<<" "<<a;
return 0;
}
cout<<"-1"<<endl;
return 0;
}
by zzx0826 @ 2020-03-10 16:41:25
对于条件
对于条件
对于条件
按上述方法模拟即可.
by zzx0826 @ 2020-03-10 16:41:32
@zbw666
by zbw666 @ 2020-03-10 16:43:30
但是你第三个条件不对啊,应该先平均分,让套数最大啊
by zbw666 @ 2020-03-10 16:43:56
@_zzx0826
by zzx0826 @ 2020-03-10 16:45:36
@zbw666 你看第二步,我们首先枚举的就是买的套数:
for(int i=n/14;i>=0;i--)
by mulberror @ 2020-03-10 17:02:37
@zbw666 我写的题解
by 村夫 @ 2020-03-10 17:47:06
switch不香吗
by deaf @ 2020-03-10 18:02:37
顶着这个头像吓谁呢