Skip to content

Instantly share code, notes, and snippets.

@fa7ad

fa7ad/ngon.cpp

Last active Mar 22, 2017
Embed
What would you like to do?
N-gon checker from codemarshal
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long polygons;
cin >> polygons;
ostringstream outputText;
for (long long c = 0; c < polygons; c++)
{
long long anglesum;
cin >> anglesum;
outputText << "Case " << c+1 << ": ";
if (anglesum % 180 == 0 && anglesum >= 180) {
long long sides = (anglesum / 180) + 2;
long double angle = (long double)anglesum / sides;
outputText << sides << " " << setprecision(10) << round(angle);
} else {
outputText << "Impossible";
}
outputText << endl;
}
cout << outputText.str();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment