codeforces水题100道 第十题 Codeforces Round #277 (Div. 2) A. Calculating Function (math)

题目链接:www.codeforces.com/problemset/problem/486/A
题意:求表达式f(n)的值。(f(n)的表述见题目)
C++代码:

#include <iostream>
using namespace std;
long long f(long long n)
{
    if (n % 2 == 0)
        return n / 2;
    else
        return n / 2 - n;
}
int main()
{
    long long n;
    cin >> n;
    cout << f(n) << endl;
    return 0;
}
C++
原文地址:https://www.cnblogs.com/moonlightpoet/p/5689010.html