#include <cstdio>
#include <iostream>
using namespace std;
bool ver[10000500];
int sieve()
{
int i, j, k=0;
//lst[k++]=2;
for (i=3 ; i<=10000000 ; i+=2)
{
if (!ver[i])
{
//lst[k++]=i;
for (j=3 ; i*j<=10000000 ; j+=2)
{
ver[i*j]=true;
}
}
}
//lst[0]=2;
return k;
}
int main()
{
sieve();
int n, i;
bool found;
while (std::cin >> n && n)
{
std::cout << n << ":" << std::endl;
if ((((n-2)&1) && !ver[n-2]) || (n-2 == 2))
{
std::cout << "2+" << n-2 << std::endl;
continue;
}
found = false;
for (i=3 ; i<=((n+1)/2) ; i+=2)
{
if (!ver[i] && !ver[n-i] && (n-i)&1)
{
std::cout << i << "+" << n-i << std::endl;
found = true;
break;
}
}
if (!found) std::cout << "NO WAY!" << std::endl;
}
return 0;
}
Thursday, November 10, 2011
[UVa] 10948 - The Primary Problem
Subscribe to:
Post Comments (Atom)
Connect Rapoo MT750S with Linux (Tested on Manjaro)
I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...
-
I like coding a lot, keeps me glued to the PC for hours. For that reason it's a need to edit the Syntax Highlighter to suit my eyes for...
-
I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...
-
Method: The problem at first glance seems too straightforward but it's not that much. Think a bit about the lines "Erin can add ...
No comments:
Post a Comment
Post your comment here. If you want to say something about programming problems, scripts, software etc, please try to be as descriptive as possible.