Created
April 16, 2021 19:07
-
-
Save ritog/0e44d57fdd13197e1dacdc381ef4f2dd to your computer and use it in GitHub Desktop.
Efficient algorithm for 486A of Codeforces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
typedef long long int lli; | |
int main() { | |
lli n{0}; | |
cin >> n; | |
if (n == 3) { | |
cout << -1; | |
} | |
else if (n % 2 == 0) { | |
cout << n / 2; | |
} | |
else if (n % 2) { | |
auto out = (((n / 2) + 1) * (-1)); | |
cout << out; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment