CSP_Sept @ 2020-03-08 10:38:27
没吸氧50吸氧85
#include <cstdio>
#include <iostream>
using namespace std;
int n;
int a1,a2,a3,minn;
bool flag=1;
int main(){
freopen("order.in","r",stdin);
freopen("order.out","w",stdout);
scanf("%d",&n);
for(int a=0;a<n/7;a++){
for(int b=0;b<n/4;b++){
int c=(n-a*7-b*4)/3;
if(7*a+4*b+3*c==n&&flag) flag=0,a1=a,a2=b,a3=c,minn=min(min(a,b),c);
else if(7*a+4*b+3*c==n&&!flag){
if(min(min(a,b),c)>minn) a1=a,a2=b,a3=c,minn=min(min(a,b),c);
else if(min(min(a,b),c)==minn){
if(a+b+c>a1+a2+a3) a1=a,a2=b,a3=c,minn=min(min(a,b),c);
}
}
}
}
if(!flag) printf("%d %d %d",a1,a2,a3);
else printf("-1");
return 0;
}
思路就是用 -1
,符合条件的挨个比较。
by YUYGFGG @ 2020-03-08 10:40:00
@CSP_Sept 这题是数论
by _Herobrine_ @ 2020-03-08 10:40:11
我跟你一样
by CSP_Sept @ 2020-03-08 10:40:38
预计得分
by Hexarhy @ 2020-03-08 10:40:45
@CSP_Sept 优化常数。
把除改为乘,然后加register
我都AC了,同样的解法不开O2最慢800ms,开了300ms
by Alarm5854 @ 2020-03-08 10:40:47
@CSP_Sept 这个可以打一个
by _Herobrine_ @ 2020-03-08 10:40:57
#include<bits/stdc++.h>
using namespace std;
int main()
{
//freopen("order.in","r",stdin);
//freopen("order.out","w",stdout);
int n;
cin>>n;
if(n<3) {cout<<-1;return 0;}
int ans1,ans2,ans3,f=0,a,b,c,z1=-1,z2=-1,y1=0,y2=0;
for(c=0;c*3<=n;c++)
{
for(b=0;b*4+c<=n;b++)
{
a=(n-c*3-b*4)/7;
if(c*3+b*4+a*7==n)
{
y1=min(min(a,b),c);
y2=a+b+c;
if(y1>z1)
{
z1=y1;
z2=y2;
ans1=a;
ans2=b;
ans3=c;
}
else if(y1==z1)
{
if(y2>z2)
{
ans1=a;
ans2=b;
ans3=c;
}
}
f=1;
}
}
}
if(!f) cout<<-1;
else printf("%d %d %d",ans1,ans2,ans3);
putchar('\n');
return 0;
}
开了吸氧之后成功搞到了85分(数量可观的分数啊QAQ)
by CSP_Sept @ 2020-03-08 10:43:23
@Hilarious_Reality thx
by Hexarhy @ 2020-03-08 10:45:40
@Herobrine 为什么你们都只有85pts?
明明这种解法可以搞到100pts的
by CSP_Sept @ 2020-03-08 10:45:40
@Hilarious_Reality 艹,A了
by HyyypRtf06 @ 2020-03-08 10:48:48
@Hilarious_Reality 明明是可以跑1e9的好吗qvq(那些O(1)的不要说了