Cod sursa(job #586050)

Utilizator andrei-alphaAndrei-Bogdan Antonescu andrei-alpha Data 30 aprilie 2011 13:29:40
Problema NumMst Scor 20
Compilator cpp Status done
Runda Algoritmiada 2011, Runda Finală, Clasele 10-12 Marime 1.83 kb
using namespace std;

#include <set>
#include <map>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cctype>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <utility>
#include <iomanip>
#include <fstream>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define oo (1<<30)
#define f first
#define s second
#define II inline
#define db double
#define ll long long
#define pb push_back
#define mp make_pair
#define Size(V) ((int)(V.size()))
#define all(V) (V).begin() , (V).end()
#define CC(V) memset((V),0,sizeof((V)))
#define CP(A,B) memcpy((A),(B),sizeof((B)))
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);++(i))
#define REP(i, N) for (int (i)=0;(i)<(int)(N);++(i))
#define FORit(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); ++it)

#define IN  "nummst.in"
#define OUT "nummst.out"

typedef vector<int> VI;
typedef pair<int,int> pi;
typedef vector<string> VS;
template<class T> string toString(T n) {ostringstream ost;ost<<n;ost.flush();return ost.str();}

int N,K,A,B;

II void scan()
{
	freopen(IN,"r",stdin);
	freopen(OUT,"w",stdout);
	scanf("%d",&N);
}

II void solve()
{
	if(!(N % 2) )
		K = 2;
	for(int k = 3;!K && k * k <= N;k += 2)
		if(!(N % k))
			K = k;
	
	if(K == 2)
	{
		printf("%d %d\n",1 * (N / K),1 * (N / K) );
		return;
	}		
	if(K == 3)
	{
		printf("%d %d\n",2 * (N / K),1 * (N / K) );
		return;
	}
	
	int mod = (K - 4) % 3;
	B = (mod == 0) ? 2 : ( (mod == 1) ? 1 : 3);   
	A = (K - B * 2) / 3;
	
	if(!A || !B)
		exit(-1);
	
	printf("%d %d\n",(N / K),(K - 1) * (N / K) );
	return;	
	
	printf("%d %d\n",(A * 3) * (N / K),(B * 2) * (N / K) );
}

int main()
{
	scan();
	solve();
	return 0;
}