(Java) Enumeration _PerfectNumber, enumeration _CounterfeitDollar, enumeration _Biorhythms

package 蓝桥杯;
import java.util.Scanner;

public class VO枚举_PerfectNumber {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner reader=new Scanner(System.in);
		int N=reader.nextInt();
		for(int a=2;a<=N;a++)
			for(int b=2;b<a;b++)
				for(int c=b;c<N;c++)
					for(int d=c;d<N;d++){
						if(a*a*a==b*b*b+c*c*c+d*d*d) {
							System.out.println("Cube = "+a+", "+"Triple = ("+b+","+c+","+d+")");
						}
					}
		reader.close();
	}

}

package 蓝桥杯;

import java.util.Scanner;
/*
2
ABCD EFGH even 
ABCI EFJL up 
ABIJ EFGH even 
ABCD EFGH even
ABCI EFGK down
ABCI EFGH even
  
  */
public class VO枚举_CounterfeitDollar {

	public static void main(String[] args) {
		Scanner reader=new Scanner(System.in);
		int X=reader.nextInt();
		String[] left=new String[3];
		String[] right=new String[3];
		String[] result=new String[3];
		while(X >0) {
			for(int i=0;i<3;i++) {
				 left[i]=reader.next();
				 right[i]=reader.next();
				 result[i]=reader.next();
				}
			for(char c='A';c<='L';c++) {
				if(IsFake(c,true,left,right,result)) {
					System.out.println(c+" is the counterfeit coin and it is light. ");
					break;
				}
				else if(IsFake(c,false,left,right,result)) {
					System.out.println(c+" is the counterfeit coin and it is heavy. ");
					break;
				}
			}
		X--;
		}
		reader.close();
	}
	static boolean IsFake(char c,boolean light,String[] left1,String[] right1,String[] result) {
		String cs=String.valueOf(c);
		String[] left;
		String[] right;
		if(light) {
			 left=left1;
			 right=right1;
		}
		else {
			left=right1;
		    right=left1;
		}
		for(int i=0;i<left.length;i++) {
			switch (result[i].charAt(0)) {
			case 'u':
					if(right[i].contains(cs)==false) {
						return false;
					}
				break;
			case 'e':
					if(left[i].contains(cs)==true||right[i].contains(cs)==true) {
						return false;
					}
				break;
			case 'd':
					if(left[i].contains(cs)==false) {
						return false;
					}
				break;
			}
		}
		return true;
	}
}

package 蓝桥杯;
import java.util.Scanner;
/*
0 0 0 0
0 0 0 100
5 20 34 325
4 5 6 7
283 102 23 320
203 301 203 40
-1 -1 -1 -1
 */
public class VO枚举_Biorhythms {

	public static void main(String[] args) {
		Scanner reader=new Scanner(System.in);
		int p=0,e,i,d,count=0,k;
		while(reader.hasNext()) {//所有数据一次性输入方法
			count++;
			p=reader.nextInt();
			e=reader.nextInt();
			i=reader.nextInt();
			d=reader.nextInt();
			if(p!=-1) {
			for(k=d+1;(k-p)%23!=0&&k<=21252;k++);
			for(;(k-e)%28!=0&&k<=21252;k+=23);
			for(;(k-i)%33!=0&&k<=21252;k+=23*28); 
			System.out.println("Case "+count+": the next triple peak occurs in "+(k-d)+" days.");
			}
		}
		reader.close();
		
	}

}
Published 20 original articles · won praise 1 · views 415

Guess you like

Origin blog.csdn.net/XMY_UPUPUP/article/details/104723721