更新
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import java.util.*;
|
||||
|
||||
public class P2966 {
|
||||
static long maxPrimeFactor(long n) {
|
||||
if (n <= 1) return 1;
|
||||
long max = -1;
|
||||
while ((n & 1) == 0) { max = 2; n >>= 1; }
|
||||
for (long i = 3; i * i <= n; i += 2) {
|
||||
while (n % i == 0) { max = i; n /= i; }
|
||||
}
|
||||
if (n > 1) max = n;
|
||||
return max;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner in = new Scanner(System.in);
|
||||
List<Long> nums = new ArrayList<>();
|
||||
while (in.hasNextLong()) nums.add(in.nextLong());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < nums.size(); i++) {
|
||||
if (i > 0) sb.append(',');
|
||||
sb.append(maxPrimeFactor(nums.get(i)));
|
||||
}
|
||||
System.out.println(sb.toString());
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.5 MiB |
Reference in New Issue
Block a user