HDACM 1395
需注意 n为偶数或者1时minimum 是不存在的。
import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner sc = new Scanner(System.in);while (sc.hasNext()) {int n = sc.nextInt();if (n%2==0||n==1) {System.out.println("2^? mod "+n+" = 1");continue;}int num = 2;int x = 1;while (num%n!=1) {num = num << 1;num = num%n;x++;}System.out.println("2^"+x+" mod "+n+" = 1");}sc.close();}
}