ENG
RUS
Timus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board
Discussion of Problem
1068
. Sum
ac (cpp)
Posted by
lhyx1990
26 Jan 2014 15:51
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
int n;
cin >> n;
if (n >= 1) {
cout << n * (n + 1) / 2;
}
else {
cout << - (-n * (-n + 1) / 2) + 1;
}
}
© 2000–2024
Timus Online Judge Team
. All rights reserved.