A. Easy Problem?
Solution
According to Euler's Formula -- Faces + Vertices — Edges = 2
Solution Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
void solvr()
{
char a, b;
cin >> a >> b;
ll one, two;
cin >> one >> two;
bool f = false;
bool v = false;
bool e = false;
if(a == 'F')
{
f = true;
}
else if(a == 'V')
{
v = true;
}
else
{
e = true;
}
if(b == 'F')
{
f = true;
}
else if(b == 'V')
{
v = true;
}
else
{
e = true;
}
if(f && v)
{
cout << "E" << endl;
cout << one + two - 2 << endl;
}
else if(f && e)
{
cout << "V" << endl;
if(a == 'E')
{
cout << one + 2 - two << endl;
}
else
{
cout << two + 2 - one << endl;
}
}
else
{
cout << "F" << endl;
if(a == 'E')
{
cout << one + 2 - two << endl;
}
else
{
cout << two + 2 - one << endl;
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int t = 1;
//cin >> t;
while(t--)
{
solvr();
}
}
B. Polygon Is Irregular?
Solution
n ==> (k-2)(180) / k [Interior angle formula for k-sided regular polygon] kn = 180k — 360 360 = k(180-n) 180-n should be divisible by 360, and k should be greater than 2
Be careful, n equal to 180 will give runtime error if not handled as division by zero is invalid.
Solution Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
void solvr()
{
ll n;
cin >> n;
if((180-n) > 0 && 360 % (180-n) == 0 && (360 / (180-n)) > 2)
{
cout << "YES" << endl;
cout << 360 / (180-n) << endl;
}
else
{
cout << "NO" << endl;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int t = 1;
//cin >> t;
while(t--)
{
solvr();
}
}
pls add more questions next time.. only 2 problem isn't enough, I think..
Euler's formula is too hard for beginners. All they can do with it is just use it's raw form. Problems that require it's application are all 2000 at least.
Also, you need to make your statements more clear. Edges/Faces/Vertices of what? And in second problem it is unclear what k is. The legend makes it seem like it's given, but it's integer you output.