brute force constructive algorithms *800

Please click on ads to support us..

Python Code:

from cmath import *
from decimal import *
import sys
def _input(): return map(int, input().split())
def _lst(): return list(map(int, input().split()))
def _int(): return int(input())

a=[0]*10001

def solves():
    n=int(input())
    if n==1:
        print(-1)
    else:
        print(n,n)


t=1
for i in range(2,10000):
    if a[i]==0:
        for j in range(i*2,10000,i):
            a[j]=1
for _ in range(0,t):
    solves()

C++ Code:

#include<bits/stdc++.h>
using namespace std;


typedef  long long int   ll;


int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll test,h,p,i,j,s,xy,n,flag=0,u,count,d,o1=0,o2=0,e,l,r,x,y,m,z,max1,x1,y1,k,x2,y2,z1,z2,sum,min1;
cin>>n;
if(n==1){
    cout<<"-1\n";
}else{
    cout<<n<<" "<<n<<"\n";
}

return 0;
}


Comments

Submit
0 Comments
More Questions

Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup