-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathFactn+m.cpp
More file actions
132 lines (120 loc) · 3.93 KB
/
Factn+m.cpp
File metadata and controls
132 lines (120 loc) · 3.93 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
A. Factorise N+M
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Pak Chanek has a prime number† n. Find a prime number m such that n+m is not prime.
† A prime number is a number with exactly 2 factors. The first few prime numbers are 2,3,5,7,11,13,…. In particular, 1 is not a prime number.
Input
Each test contains multiple test cases. The first line contains an integer t (1≤t≤104) — the number of test cases. The following lines contain the description of each test case.
The only line of each test case contains a prime number n (2≤n≤105).
Output
For each test case, output a line containing a prime number m (2≤m≤105) such that n+m is not prime. It can be proven that under the constraints of the problem, such m always exists.
If there are multiple solutions, you can output any of them.
Example
inputCopy
3
7
2
75619
outputCopy
2
7
47837
Note
In the first test case, m=2, which is prime, and n+m=7+2=9, which is not prime.
In the second test case, m=7, which is prime, and n+m=2+7=9, which is not prime.
In the third test case, m=47837, which is prime, and n+m=75619+47837=123456, which is not prime.
*/
#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <chrono>
#include <complex>
using namespace std;
#define ll long long
#define ld long double
#define ui unsigned int
#define ull unsigned ll
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define hashmap unordered_map
#define hashset unordered_set
#define lb lower_bound
#define ub upper_bound
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define foi(n) for(ll i=0;i<n;i++)
#define foj(n) for(ll j=0;j<n;j++)
#define fok(n) for(ll k=0;k<n;k++)
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define forrr(i,b,a) for(ll i=b;i>=a;i--)
#define forrrr(i,a,b,k) for(ll i=a;i<b;i=i+k)
#define graph vector<vector<ll>>
#define sz(v) v.size()
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef pair< ll, pll> plll;
typedef queue<ll> qll;
typedef vector<plll> vplll;
typedef vector<set<ll>> vsll;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef map<ll, vll> mvll;
typedef map<vll, ll> mvlll;
typedef map<char, ll> mcl;
typedef map<pair<ll, ll>, ll> mplll;
typedef unordered_map<char, ll> umcl;
typedef unordered_map< ll, char> umlc;
typedef unordered_map< ll, ld> umld;
typedef map<int, string> mis;
typedef pair<string, int> psi;
typedef pair<string, string> pss;
typedef priority_queue <ll> pq;
typedef priority_queue<pii, vector<pii>, greater<pii> > pqq;
typedef priority_queue<ll, vector<ll>, greater<ll>> prq;
const ll MOD = 1000000007;
const ll mod = 998244353;
ld PI = 3.1415926535897;
void solve();
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input2.txt", "r", stdin);
freopen("error1.txt", "w", stderr);
freopen("output2.txt", "w", stdout);
#endif
ll t; cin >> t;
while (t--)
{
solve();
cout << "\n";
}
cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
return 0;
}
void solve() {
ll n;
cin >> n;
if (n == 2) cout << 7;
else cout << 3;
}