1 条题解
-
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
信息
- ID
- 2474
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 4
- 标签
- 递交数
- 20
- 已通过
- 18
- 上传者