1 条题解
-
0
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; int ans = 0; cin >> ans; for(int i = 1; i < n; i++){ int num; cin >> num; if(i % 2 == 1){ // 第2、4个数为奇,执行加法 ans += num; } else { // 第3、5个数为偶,执行减法 ans -= num; } } cout << ans << '\n'; } int main() { ios::sync_with_stdio(0); cin.tie(0); solve(); return 0; }
- 1
信息
- ID
- 1138
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- (无)
- 递交数
- 14
- 已通过
- 11
- 上传者