Created
August 4, 2013 07:15
-
-
Save igauravsehrawat/6149534 to your computer and use it in GitHub Desktop.
codechef:: splitting candies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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