mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-07-07 18:06:58 +08:00
更新了许多
This commit is contained in:
32
最美苹果数.cpp
Normal file
32
最美苹果数.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main(){
|
||||
int N1;
|
||||
int N2;
|
||||
int N3;
|
||||
int Number;
|
||||
cin >>N1>>N2>>N3;
|
||||
if(N3<=2 || N2<=1 || N1<=0){
|
||||
cout <<"-1";
|
||||
}
|
||||
else{
|
||||
if(N2>=N3){
|
||||
Number=N2-N3+1;
|
||||
if(N1>=N3-1){
|
||||
Number=N2-N3+1+N1-N3+2;
|
||||
}
|
||||
else{
|
||||
cout <<Number;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(N1>=N2){
|
||||
Number=N1-N2+1;
|
||||
}
|
||||
else{
|
||||
cout <<Number;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user