-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSumOfTwoNum.cpp
More file actions
38 lines (37 loc) · 776 Bytes
/
SumOfTwoNum.cpp
File metadata and controls
38 lines (37 loc) · 776 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
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
int samples;
cin >> samples;
while (samples--)
{
int n;
cin >> n;
ll div = n / 2;
ll rem = n % 2;
ll cnt = 0;
if (rem != 0)
{
if (n % 10 == 9)
{
ll second = 0;
cnt = floor(log10(n));
while (cnt--)
{
second+=5*pow(10,cnt);
}
cout << n-second << " " << second << endl;
}
else
{
cout << (n+1)/2 << " " << (n-1)/2 << endl;
}
}
else
{
cout << div << " " << div << endl;
}
}
}