codeforces 472A problem solution in simple c/c++

// 472A.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;
int main()
{
int n,v=0,b=0,m=0,e=0,cc=0,bb=0;
cin >> n;
if (n % 2 == 0)
{
v = n;
v = v / 2;
if (v % 2 == 0)
{
b = v;
m = v;
}
else if (v % 2 == 1)
{
b = v - 1;
m = v + 1;

}
}
else if (n % 2 == 1)
{
e = n;
e = e / 2;
b = e;
m = e + 1;
for (int j = 0;j < m;j++)
{
for (int i = 2;i < m / 2;i++)
{
if (b%i == 0)
{
cc++;
}
if(m%i==0)
{
bb++;
}
}
if (bb == 0 && cc == 0)
{
b = b - 1;
m = m + 1;
bb = 0;
cc = 0;
}
else if (bb > 0 && cc == 0)
{
b = b - 1;
m = m + 1;
bb = 0;
cc = 0;
}
else if (cc > 0 && bb == 0)
{
b = b - 1;
m = m + 1;
bb = 0;
cc = 0;
}
else if (bb > 0 && cc > 0)
{
break;
}
}

}
cout << b << " " << m;


}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file

Comments

Popular posts from this blog

codeforces 339A solution in c/c++

codeforces 520A problem solution in c/c++