简单的计算题,用n对k取余,如果余数为0,则输出k的值,否则输出(k-余数)的值。
import java.util.Scanner;
public class p9226 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc .nextInt();
int k = sc.nextInt();
int result = n % k;
if(result == 0){
System.out.println(k);
} else {
System.out.println(k-result);
}
}
}