-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem3.cpp
More file actions
41 lines (39 loc) · 948 Bytes
/
problem3.cpp
File metadata and controls
41 lines (39 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include<bits/stdc++.h>
#include<algorithm>
typedef unsigned long long int ll;
using namespace std;
bool findPrimes(ll n, bool primes[]){
primes[0] = primes[1] = false;
for (ll i=2; i<=n; i++)
primes[i] = true;
for (ll i=2; i*i<=n; i++){
if (primes[i] == true){
for (ll j=i*i; j<=n; j += i)
primes[j] = false;
}
}
}
int main()
{
ll t;
cin>>t;
while(t--){
ll n;
cin>>n;
bool primes[n+1];
findPrimes(n, primes);
bool found=false;
for (ll i=0; i<n; i++){
if (primes[i] && primes[n-i]){
if(i == (n-i))
cout<<"impossible\n";
else
cout << i << " " <<n-i<<endl;
found = true;
break;
}
}
if(!found)
cout<<"impossible\n";
}
}