WDC之力 @ 2020-03-08 08:53:25
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a,b,c;
cin>>n;
if(n<3){
cout<<-1<<endl;
}
for(int i=1;i<=n/7;i++){
for(int j=1;j<=n/4;j++){
int k=(n-i*7-j*4)/3;
int Min=2147483647;
int min=2147483647;
if(Min>i){
Min=i;
}
if(Min>j){
Min=j;
}
if(Min>k){
Min=k;
}
if(min>a){
min=k;
}
if(min>b){
min=b;
}
if(min>c){
min=c;
}
if(n==3*k+4*j+7*i){
if(Min>min){
a=i;b=j;c=k;
}
if(Min==min){
if((a+b+c)<=(i+j+k)){
a=i;b=j;c=k;
}
}
}
}
}
cout<<a<<" "<<b<<" "<<c;
return 0;
}
by Luban @ 2020-03-08 08:56:07
我更惨OK?
O(1)算法
95分
n=0的时候会炸
555救命啊
by lu_fish @ 2020-03-08 08:57:25
O(1)?
by fresh_boy @ 2020-03-08 08:58:50
我O(n²),哈哈
by WDC之力 @ 2020-03-08 09:00:47
@唱歌的向日葵 我O(n²)为什么通不过
by fresh_boy @ 2020-03-08 09:02:32
您确定您的k是整除的?
by WDC之力 @ 2020-03-08 09:06:52
后面if有判断,不是整除的就不会执行 https://www.luogu.com.cn/record/31490460
by Heap_Sort @ 2020-03-08 09:08:25
@可爱小鲁班 特判
by Luban @ 2020-03-08 09:23:31
@ZZY729 对头
by 江户川·萝卜 @ 2020-03-08 09:28:20
@可爱小鲁班 +1
by lndjy @ 2020-03-08 09:29:46
可以看下我题解顺便点个赞