1 solutions
-
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
Information
- ID
- 488
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 6
- Tags
- (None)
- # Submissions
- 210
- Accepted
- 57
- Uploaded By