#include
using namespace std;
int main()
{
long long int t,n1,n2,k,l;
cin>>t;
for (int i=0;i<t;i++)
{
cin>>n1>>n2;
k=n1;
l=n2;
while(n1 != n2)
{
if(n1>n2)
n1-=n2;
else
n2-=n1;
}
cout<<n1<<" "<<(k*l)/n1<<endl;
}
return 0;
}
can someone help me, trying to submit this code but getting wrong answer.Tried another questions many time still not getting it right.This code displays hcf and lcm of two given numbers.
Is there any role of constraints provided?
or some specific way to output the answer?
i’m a beginner please help.
just check out that your program is following the constraints given in the problem.
try to take input just as the given in constraints. This will help you to determine whether your logic is correct or not.
Hope this helps you!!
int main(){
int t=0,n=0,i=1,j=0,ans=1 ;
cin >> t ;
while(i<=t){
cin >> n ;
for(j=n;j>=1;j–){
ans *=j ;
}
cout << ans << endl;
ans = 1;
i++ ;
}
return 0;
}
THIS IS SHOWING WRONG ANSWER . WHAT IS THE PROBLEM?
You have to find the MAXIMUM difference in scores, and the player with the lead wins.
In your case, "lead = lead + p1-p2 " is taking into account the previous lead/lead in previous round, while the example clearly showed this is not the case.
I advice, please give another attempt in understanding the Q, and if you’re still facing problem, look at its solution here
Hi. I am using System.out.println in java to print my answer. Would it cause new line trouble, giving WA? All my answers seem correct with given test cases and few more that I generated by my self.
def remove_dot(this_list,value):
while value in this_list:
this_list.remove(value)
def check(list2):
if(list2==[]):
return “Valid”
elif(list2[0]==‘T’ or list2[len(list2)-1]==‘H’):
return “Invalid”
else :
count=0
for i in range(0,len(list2)-1,2):
if(list2[i] is ‘H’ and list2[i+1] is ‘T’):
count+=1
if((count*2) is len(list2)):
return “Valid”
else :
return “Invalid”
R=int(input())
L=[]
str=[]
dot=’.’
ans=[]
for i in range(0,R):
L.append(int(input())) #for j in range(0,L[i]):
value=input()
list=[]
list[:0]=value
remove_dot(list,dot)
ans.append(check(list))
for i in range(0,R):
print(ans[i])
This is my python code i run in my machine it gives me right output but when i submit in SmackDown contest it tells wrong answer i am trying from 2 days