1 solutions
-
0
C++ :
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; if(n % 2 == 0){ cout<<n / 2 + n / 2 + 1<<endl; } else{ cout<<n / 2 + 1<<endl; } return 0; }
Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int s; if(n % 2 == 1){ s = (n + 1) / 2; System.out.println(s); }else if(n % 2 == 0){ s = n + 1; System.out.println(s); } } }
- 1
Information
- ID
- 10080
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By