村夫 @ 2020-03-09 11:00:38
#include<bits/stdc++.h>
using namespace std;
long long m,a,b,c,t,u;
int main(){
cin>>m;
switch(m){
case 1:cout<<-1;return 0;
case 2:cout<<-1;return 0;
case 5:cout<<-1;return 0;
default:
t=m%14;
a+=(m-t)/14;
b+=(m-t)/14;
c+=(m-t)/14;
switch(t){
case 1:a=a-1;b=b+2;break;
case 2:a=a-1;c=c+3;break;
case 3:c=c+1;break;
case 4:b=b+1;break;
case 5:a=a-1;c=c+4;break;
case 6:c=c+2;break;
case 7:b=b+1;c=c+1;break;
case 8:b=b+2;break;
case 9:c=c+3;break;
case 10:b=b+1;c=c+2;break;
case 11:b=b+2;c=c+1;break;
case 12:c=c+4;break;
case 13:b=b+1;c=c+3;break;
}
}
if(m-a*7-b*4-c*3!=0)
cout<<-1;
else
cout<<a<<" "<<b<<" "<<c;
return 0;
}
by 村夫 @ 2020-03-09 11:08:16
我是新手 大神见谅
by pocafup @ 2020-03-09 11:09:08
#include <iostream>
using namespace std;
int a,b;
void solve(){
cin >> a >> b;
cout << a+b;
}//这东西叫function
int main(){
solve();//这东西叫comment
return 0;
}
by answerend42 @ 2020-03-09 11:11:44
@村夫 考虑了 0 0 0
的情况吗
by 村夫 @ 2020-03-09 11:20:22
#include<bits/stdc++.h>
using namespace std;
long long m,a,b,c,t,u;
int main(){
cin>>m;
switch(m){ //看看m的值
case 1:cout<<-1;return 0; //不可把钱花完
case 2:cout<<-1;return 0;
case 5:cout<<-1;return 0;
default: //可以把钱花完
t=m%14; //用m模14,每一个14 a,b,c都加一
a+=(m-t)/14;
b+=(m-t)/14;
c+=(m-t)/14;
switch(t){ //看看t(m%14)的值
case 1:a=a-1;b=b+2;break;
case 2:a=a-1;c=c+3;break;
case 3:c=c+1;break;
case 4:b=b+1;break;
case 5:a=a-1;c=c+4;break;
case 6:c=c+2;break;
case 7:b=b+1;c=c+1;break;
case 8:b=b+2;break;
case 9:c=c+3;break;
case 10:b=b+1;c=c+2;break;
case 11:b=b+2;c=c+1;break;
case 12:c=c+4;break;
case 13:b=b+1;c=c+3;break;
}
}
cout<<a<<" "<<b<<" "<<c;
return 0;
}
by 村夫 @ 2020-03-09 11:21:41
@answerend42 输出没问题
by answerend42 @ 2020-03-09 15:24:11
@村夫 我大概找到你的问题了,0 0 5
而不是0 3 1
by 村夫 @ 2020-03-10 17:42:23
@answerend42 AC 了Thanks♪(・ω・)ノ谢谢