mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 14:36:27 +00:00
714. 连续奇数的和 1
https://www.acwing.com/problem/content/submission/code_detail/14061154/
This commit is contained in:
parent
12cea7d0b8
commit
58db81b52b
23
AcWing/714/714.cpp
Normal file
23
AcWing/714/714.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
const char endl = '\n';
|
||||||
|
|
||||||
|
int x, y, ans;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
|
||||||
|
cin >> x >> y;
|
||||||
|
|
||||||
|
if (y < x) std::swap(x, y);
|
||||||
|
|
||||||
|
for (int i = x + 1; i < y; i++) {
|
||||||
|
if (i & 1) ans += i;
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << ans << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user