Guest User

Untitled

a guest
Apr 20th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3.  
  4. public class Solution {
  5. public static void main(String[] args) {
  6. Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
  7. int t = in.nextInt();
  8. for (int i = 1; i <= t; ++i) {
  9. long n = in.nextLong();
  10. long x = 2;
  11. while (true) {
  12. long rhs = n * x - n + 1;
  13. long lhs = 1;
  14. while (lhs < rhs) {
  15. lhs *= x;
  16. }
  17. if (lhs == rhs) {
  18. break;
  19. } else {
  20. ++x;
  21. }
  22. }
  23. System.out.println("Case #" + i + ": " + x);
  24. }
  25. in.close();
  26. }
  27. }
Add Comment
Please, Sign In to add comment