First, solve the problem. Then, write the code. ” - John Johnson

It's not at all important to get it right the first time. It's vitally important to get it right the last time. ” - Andrew Hunt and David Thomas

Sunday, July 20, 2014

GCD The Largest

Author : Jisan
Programming language : Java 
Difficulty : Easy
Status : Accepted
Problem number : UVA-12708
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4446

Code:

import java.util.*;
public class Uva_12708 {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int a=in.nextInt();
while(a>0){
long b=in.nextLong();
if(b%2!=0){
b--;
}
System.out.println(b/2);
a--;
}
}

}

No comments:

Post a Comment