fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main{
  4. public static void main(String[] args){
  5. Scanner sc = new Scanner(System.in);
  6. int n = sc.nextInt();
  7. int k = sc.nextInt();
  8. int sum = 0;
  9. while(n > 0){
  10. int rem = n % 10;
  11. sum = sum + rem;
  12. n = n/10;
  13. }
  14. System.out.println(sum % k == 0 ? "true" : "false");
  15. }
  16. }
Success #stdin #stdout 0.12s 54436KB
stdin
5
1 1 1 34
1200
2 3 2 10
100 10 1
3 3 3 3
1 2 3
4 2 2 7
5 8
999 1 999 6
3
stdout
true