public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int nums = sc.nextInt(); for (int i = 0; i<nums; i++){ int N = sc.nextInt(); maxandmin(N); } } public static void maxandmin(int N){ if (N==1||N==2){ System.out.println("1 1"); //如果n是1或者2就输出 1 1 return; } //之后每4个一组 0011 int min = getmin(N); int max = N-getmin(N-1); System.out.println(min + " " + max); } public static int getmin(int N){ int temp = (N-2)%4; //temp临时值接住 if (temp==1 || temp==2){ return 0; } else return 1; } }
结果
多多的电子字典
题目
分析
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n=input.nextInt(); //n个a int m=input.nextInt(); //m个b int k=input.nextInt(); //第k小的单词 System.out.println(dik(n,m,k)); }
public static String dik(int n,int m,int k){ String res="123";