2022-9-11

安全密码

import java.util.Scanner;

public class 安全密码 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner=new Scanner(System.in);
		int n=scanner.nextInt();//第一行输入n
		String[] strsStrings=new String[n];//n个字符串
		for(int i=0;i<strsStrings.length;i++) {//for循环键盘输入n个字符串
			strsStrings[i]=scanner.next();
		}
		for(int i=0;i<strsStrings.length;i++) {
			//四种情况
			boolean a1=false;
			boolean a2=false;
			boolean a3=false;
			boolean a4=false;
			
			boolean result=false;
			char[] ch=strsStrings[i].toCharArray();//转换成字符数组,为之后循环遍历字符做准备
			if(strsStrings[i].length()>=8&&strsStrings[i].length()<=16) {
				for(int j=0;j<ch.length;j++) {//遍历字符串的每个字符
					 if ('A' < ch[j] && ch[j] < 'Z') {
	                        a1 = true;
	                    } else if ('a' < ch[j] && ch[j] < 'z') {
	                        a2 = true;
	                    } else if ('0' < ch[j] && ch[j] < '9') {
	                        a3 = true;
	                    } else if (ch[j] == '~' || ch[j] == '!' || ch[j] == '@' || ch[j] == '#'
	                    || ch[j] == '$' || ch[j] == '%' || ch[j] == '^') {
	                        a4 = true;
	                    }
					 if ((a1 && a2 && a3) || (a1 && a2 && a4) || (a2 && a3 && a4) || (a1 && a3 && a4)) {
	                        result = true;
	                        break;
				}
				
			
			}
			}
			if (result) {
	            System.out.println("YES");
	        } else {
	            System.out.println("NO");
	        }		
		}
	}
}

素数回文

import java.util.Scanner;

public class 素数回文 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner=new Scanner(System.in);
		int a=scanner.nextInt();
		int b=scanner.nextInt();
		loop:for(int i=a;i<=b;i++) {
			String string=Integer.toString(i);
			String s1=new StringBuffer(string).reverse().toString();//反转字符串
			if(string.equals(s1)) {
				for(int j=2;j<=i;j++) {
					if(i%j==0&&i!=j) {
						continue loop;
					}
					if(i%j==0&&i==j) {
						System.out.println(i);
						continue loop;
					}
				}
			}
		}

	}

}

递增三元组

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class 递增三元组 {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader bReader=new BufferedReader(new InputStreamReader(System.in));
		int N=Integer.parseInt(bReader.readLine());
		int[] a=new int[N+1];
		int[] b=new int[N+1];
		int[] c=new int[N+1];
		String[] splitStrings=bReader.readLine().split(" ");
		for(int i=1;i<=N;i++) {
			a[i]=Integer.parseInt(splitStrings[i-1])+1;
		}
		splitStrings=bReader.readLine().split(" ");
		for(int i=1;i<=N;i++) {
			b[i]=Integer.parseInt(splitStrings[i-1])+1;
		}
		splitStrings=bReader.readLine().split(" ");
		for(int i=1;i<=N;i++) {
			c[i]=Integer.parseInt(splitStrings[i-1])+1;
		}
		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);
		int i=1,k=1;
		long ans=0;
		for(int j=1;j<=N;j++) {
			while(i<=N&&b[j]>a[i]) {
				i++;
			}
			while(k<=N&&c[k]<=b[j]) {
				k++;
			}
			ans+=(long)(i-1)*(N-k+1);
		}
		System.out.println(ans);

	}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值