Codeforces 1372B. Omkar and Last Class of Math Solution
Solution in C++:
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t,n,i,f;
- cin>>t;
- while(t--)
- {
- f=0;
- cin>>n;
- if(n%2)
- {
- for(i=2; i*i<=n; i++)
- {
- if(n%i==0)
- {
- cout<<n/i<<" "<<n-(n/i)<<endl;
- f=1;
- break;
- }
- }
- if(f==0)
- cout<<"1 "<<n-1<<endl;
- }
- else
- cout<<n/2<<" "<<n/2<<endl;
- }
- }
No comments