dico @ 2020-03-08 12:15:39
最后两个点WA
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,minn,maxx,A[100001],B[100001],C[100001],to;
int main()
{
cin>>n;
if(n%14==0)cout<<n/14<<' '<<n/14<<" "<<n/14;
else
{
for(a=0;a*7<=n;a++)
for(b=0;b*4+7*a<=n;b++)
{
c=n-7*a-4*b;
if(c%3==0&&c>=0)
A[to]=a,B[to]=b,C[to++]=c/3;//,cout<<a<<' '<<b<<" "<<c/3<<endl;
}
if(to==0){cout<<-1;return 0;}
for(int i=0;i<to;i++)
minn=max(minn,min(A[i],min(B[i],C[i])));
for(int i=0;i<to;i++)
if(minn==min(A[i],min(B[i],C[i])))maxx=max(maxx,A[i]+B[i]+C[i]);
else A[i]=-1;
for(int i=0;i<to;i++)
if(A[i]!=-1&&maxx==A[i]+B[i]+C[i])
{
cout<<A[i]<<' '<<B[i]<<' '<<C[i];
return 0;
}
}
}
by IntrepidStrayer @ 2020-03-08 12:18:25
为啥你们都枚举件数 就我枚举套数再dfs的吗
by HyyypRtf06 @ 2020-03-08 12:20:25
只有我把n砍到500后三方暴力的吗?
by MY(一名蒟蒻) @ 2020-03-08 12:25:12
直接暴力结果
暴力代码(经过血的教训才打出来的)
#include <cstdio>
int n,a,b,c;
int main()
{
// freopen("order.in","r",stdin);freopen("order.out","w",stdout);
scanf("%d",&n);
if(n == 0) {printf("0 0 0"); return 0;}
if((n-15)%14 == 0) {printf("%d %d %d",(n-15)/14,(n-15)/14,(n-15)/14+5); return 0;}
if(n < 3 || n == 5) {printf("-1"); return 0;}
if(n == 3) {printf("0 0 1"); return 0;}
if(n == 4) {printf("0 1 0"); return 0;}
if(n == 6) {printf("0 0 2"); return 0;}
if(n == 7) {printf("0 1 1"); return 0;}
if(n%14 == 0) {printf("%d %d %d",n/14,n/14,n/14); return 0;}
a=n/7;n=n%7;
if(n == 6) c=2;
if(n == 5) {a--; c=4;}
if(n == 4) b++;
if(n == 3) c++;
if(n == 2) {a--; c=3;}
if(n == 1) {b=2; a--;}
if(a%2 == 0) printf("%d %d %d",a/2,b+a/2,c+a/2);
else printf("%d %d %d",a/2,b+a/2+1,c+a/2+1);
// fclose(stdin);fclose(stdout);
return 0;
}
by _JEB_ @ 2020-03-08 12:25:37
三方肯定会超时吧
@HyyypRtf06
by IntrepidStrayer @ 2020-03-08 12:26:46
打表AC
by _JEB_ @ 2020-03-08 12:26:51
@MY(一名蒟蒻)
我们俩一秒内一起说的
by _JEB_ @ 2020-03-08 12:27:13
@fhh_orz
我们俩也是!
by IntrepidStrayer @ 2020-03-08 12:31:11
我谔谔
by HyyypRtf06 @ 2020-03-08 13:07:15
@Charlie___j 注意我说的话:把n砍到500
by _JEB_ @ 2020-03-08 13:08:46
我谔谔
@HyyypRtf06