若干个非负整数c,c的位数<=30 每行一个c
每一个c的结果占一行 1) 若存在满足 c%k == 0 的k,输出所有这样的k,中间用空格隔开,最后一个k后面没有空格。 2) 若没有这样的k则输出"none" 注意整数溢出问题 不要对-1进行计算
30 72 13 -1
2 3 5 6 2 3 4 6 8 9 none
import java.util.Scanner;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
String str = in.next();
if (str.equals("-1")) {
break;
}
BigInteger c = new BigInteger(str);
boolean find = false;
for (int k = 2; k <= 9; k++) {
if (c.mod(new BigInteger(String.valueOf(k)))
.equals(new BigInteger("0"))) {
find = true;
System.out.print(k);
for (int k1 = k + 1; k1 <= 9; k1++) {
if (c.mod(new BigInteger(String.valueOf(k1)))
.equals(new BigInteger("0"))) {
System.out.print(" " + k1);
}
}
System.out.println();
break;
}
}
if (!find) {
System.out.println("none");
}
}
}
} import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
while(in.hasNext())
{
BigInteger b=in.nextBigInteger();
int len=0;
for(int j=2;j<=9;j++)
{
BigInteger t=BigInteger.valueOf(j);
if(b.remainder(t).equals(BigInteger.ZERO))
{
len++;
System.out.print(j+" ");
}
}
if(len==0)
{
System.out.println("none");
}else
{
System.out.println();
}
}
}
}
import java.math.BigInteger;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (input.hasNext()) {
String c = input.nextLine();
boolean flag = true;
if ("-1".equals(c)) {
break;
} else {
BigInteger big = new BigInteger(c);
for (int i = 2; i <= 9; i++) {
if (big.mod(BigInteger.valueOf(i)).intValue() == 0) {
if (!flag) {
System.out.print(" ");
}
System.out.printf("%d", i);
flag = false;
}
}
}
if (flag) {
System.out.println("none");
} else {
System.out.println();
}
}
}
} import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
while (reader.hasNext()) {
String input = reader.next();
ArrayList<Integer> res = new ArrayList<>();
for (int divisor = 2; divisor <= 9; ++divisor) {
int mod = 0;
for (int j = 0; j < input.length(); ++j) {
int digit = input.charAt(j) - '0';
mod = (mod * 10 + digit) % divisor;
}
if (mod == 0)
res.add(divisor);
}
StringBuilder sb = new StringBuilder();
if (res.size() > 0) {
for (int i: res) {
sb.append(i+" ");
}
System.out.println(sb.substring(0, sb.length()-1).toString());
} else {
System.out.println("none");
}
}
}
}