Luban @ 2020-03-08 08:52:46
#include<bits/stdc++.h>
using namespace std;
int bb[]={0,0,0,0,1,0,0,1,2,0,1,2,0,1};
int cc[]={0,0,0,1,0,0,2,1,0,3,2,1,4,3};
int main()
{
int n,a,b,c;
cin>>n;
if (n<3||n==5)
{
cout<<-1<<endl;
return 0;
}
a=n/14;
b=n/14;
c=n/14;
n%=14;
if (!n)
{
cout<<a<<" "<<b<<" "<<c<<endl;
return 0;
}
if (n<3||n==5)
{
n+=14;
a--;
b--;
c--;
if (n==15)
{
cout<<a<<" "<<b<<" "<<c+5<<endl;
}
if (n==16)
{
cout<<a<<" "<<b+1<<" "<<c+4<<endl;
}
if (n==19)
{
cout<<a<<" "<<b+1<<" "<<c+5<<endl;
}
return 0;
}
cout<<a<<" "<<b+bb[n]<<" "<<c+cc[n]<<endl;
return 0;
}
Test1错了,其他AC
据检测为n=0时这玩意会直接输出-1,死定了
by Aw顿顿 @ 2020-03-08 09:13:11
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
int s=0,f=1;
char ch=getchar();
while((ch<'0'||ch>'9')&&ch!=EOF){
if(ch=='-') f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
s=s*10+ch-'0';
ch=getchar();
}
return s*f;
}
inline int small(int x,int y,int z){
if(x<=y&&x<=z)return x;
if(z<=y&&z<=x)return z;
if(y<=x&&y<z)return y;
}
int n,a,b,c;
signed main()
{
n=read();
if(n<3){
puts("-1");
return 0;
}
if(n%14==0){
int s=n/14;
printf("%lld %lld %lld\n",s,s,s);
return 0;
}
for(register int i=0;i<n/7;++i)for(register int j=0;j<n/4;++j){
int k=(n-i*7-4*j)/3;
if(k<=0)break;
if(7*i+4*j+3*k==n){
int s1=small(i,j,k);
int s2=small(a,b,c);
if(s1>s2)a=i,b=j,c=k;
else if(s1==s2&&i+j+k>a+b+c)a=i,b=j,c=k;
}
}
printf("%lld %lld %lld\n",a,b,c);
return 0;
}
暴力,可是还是75分
by HyyypRtf06 @ 2020-03-08 09:17:05
哇!!!泥萌有我惨吗……
我今天起来发现我的最后一行main();
没注释,100pts->0pts……然后T2把freopen注释了……T3连freopen都没打【真·保灵……】
by DreamFox @ 2020-03-08 09:17:30
我是打表找规律,满分
by HyyypRtf06 @ 2020-03-08 09:17:36
wtnl(果然还是粗心/lb
by Luban @ 2020-03-08 09:27:12
@Aw顿顿 现在3级都会快读了,教教我啊,我会的算法很少的
by yagyagyag @ 2020-03-08 09:44:18
我也是test1错了,95分
by Luban @ 2020-03-08 09:44:40
@flys 我去,我也可以满分,只要不毒瘤就行
by 村夫 @ 2020-03-08 20:26:35
我只90 o( ̄︶ ̄)o