4 solutions
-
1
- 1
Information
- ID
- 539
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 2
- Tags
- # Submissions
- 59
- Accepted
- 36
- Uploaded By
#include<iostream>
#include<iomanip>
using namespace std;
int p=8,w;
char x;
int main(){
cin>>w>>x;
if(w>1000){
if(w%500==0) p+=(4*(w-1000)/500);
else p+=(4*((w-1000)/500+1));
}
if(x=='y') p+=5;
cout<<p<<"\n";
}
if嵌套
练习c++两年半,志在让老师白吃干饭。 题库里题解不断,看名就知道是我在干。
#include<bits/stdc++.h>
using namespace std;
int main()
{
int w,s = 8;
string a;
cin>>w>>a;
if(w > 1000)
{
if(w % 500 == 0)
{
s+=(((w - 1000) / 500) * 4);
}
else
{
s+=(((w - 1000) / 500 + 1) * 4);
}
}
if(a == "y") s += 5;
cout<<s<<endl;
}
判断太多赘余了
#include <bits/stdc++.h>
using namespace std;
int w,s=8;
int main(){
string a;
cin>>w>>a;
if(w>1000){
if(!w%500) s+=((w-1000)/500)*4;
else s+=((w-1000)/500+1)*4;
}
if(a=="y") s+=5;
cout<<s<<endl;
return 0;
}
//简单的分类讨论而已
//比楼下那位好点吧......
嘿
郭巨
By signing up a ZXOJ universal account, you can submit code and join discussions in all online judging services provided by us.