Skip to content

Instantly share code, notes, and snippets.

@igauravsehrawat
Created August 4, 2013 07:15
Show Gist options
  • Save igauravsehrawat/6149534 to your computer and use it in GitHub Desktop.
Save igauravsehrawat/6149534 to your computer and use it in GitHub Desktop.
codechef:: splitting candies
import java.util.Scanner;
public class Main {
public static void main(String args[]){
//upper limit for n and k are 2^33 -1
Scanner scan =new Scanner(System.in);
Long n;
Long k;
Long distri ;
Long remainder;
Integer testcases=scan.nextInt();
for(int i=0;i<testcases;i++){
n=scan.nextLong();
k=scan.nextLong();
if( k==0){
distri= new Long(0);
remainder= new Long(0);
}
else if( k!=0 && n==0){
distri=new Long(0);
remainder=k;
}
else if(n >k){
distri=new Long(0);
remainder=k;}
else{
distri=k/n;
remainder=k%n;
}
System.out.println(distri+" " + remainder);
}
//System.out.println("testing");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment