1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10673 Play with Floor and Ceil
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=18&page=show_problem&problem=1614
*
* @author Anton Pavlushko, IBB7B,
* @version 1.0, 03/12/2010
*
* Status : Accepted
* Runtime: 1.872
*/

import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String current_line, empty = "";
int number, border, i, j, m, length, number_local;
int primes [];
Iterator iter;
int znak,count,count_already,multiply;
StringTokenizer input_string;
boolean status, at_least_one;
double x,k,p_q,p,q,floor,ceil;

try {
current_line=in.readLine();
input_string = new StringTokenizer(current_line);
count=Integer.parseInt(input_string.nextToken());

for(i=0;i<count;i++) {
current_line=in.readLine();
input_string = new StringTokenizer(current_line);
x=Double.parseDouble(input_string.nextToken());
k=Double.parseDouble(input_string.nextToken());

p_q=Math.ceil(x/k);
if (p_q==0) p_q=1;
p_q=Math.floor(x/p_q);

floor=Math.floor(x/k);
ceil=Math.ceil(x/k);

for(p=0;p<=p_q;p++) {
for(q=0;q<=p_q;q++) { //ne effektivno, mozhno prosto +/-1
if (x==(p*floor+q*ceil)) {
System.out.println(Math.round(p)+" "+Math.round(q));
p=p_q;
q=p_q;
}
}
}
}//for

} // end try
catch (IOException ee) {
System.err.println("Error: " + ee);
}
}
}