第十一屆藍橋杯大賽軟體類省賽Java大學B組(第一場)

2020-10-06 11:00:07

第十一屆藍橋杯大賽軟體類省賽Java大學B組(第一場)

在這裡插入圖片描述
在這裡插入圖片描述

YcRikGSunlRzgDlvRwYkXkrGWWhXaA

在這裡插入圖片描述
在這裡插入圖片描述
在這裡插入圖片描述
在這裡插入圖片描述

def fib(n):
    x = 1
    y = 1
    cnt = 2
    while cnt < n:
        ans = x + y
        y = x
        x = ans
        cnt += 1
    return ans
import java.math.BigInteger;

public class Main {
	
	public static void main(String[] args) {
		BigInteger a = new BigInteger("63906981155943558665134927398528713938196200043745871355763079787265151995322001898071485437809065533306267303596007174873825024273095647974649878913616096766604248066008649395662343764260286534059003290654116126957362406745866507935366369712842138930014038888572227398490742287722358671367235709189166548965693916054419169307250217586108972590100204080980670597873094617540854443783530320723473081393553497241453257464515");
		BigInteger b = new BigInteger("2109055108727958115216736026700200421586510355834736601003381505407930071607408184616335724173657853423941515");
		System.out.println(gcd(a, b));
	}
	
	static BigInteger gcd(BigInteger a, BigInteger b) {
		return b.equals(BigInteger.ZERO) ? a : gcd(b, a.mod(b));
	}

}
6765

在這裡插入圖片描述

import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		char[] a = s.toCharArray();
		int upper = 0, lower = 0, num = 0;
		for(int i = 0; i < a.length; i ++) {
			if(Character.isUpperCase(a[i])) upper ++;
			else if(Character.isLowerCase(a[i])) lower ++;
			else if(Character.isDigit(a[i])) num ++;
		}
		System.out.println(upper);
		System.out.println(lower);
		System.out.println(num);
	}

}

在這裡插入圖片描述

import java.util.Scanner;

public class Main {
	
	static long mod = 123456789;
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		long ans = 0;
		for(long i = 1; i <= n; i ++) {
			ans = (ans + quickPow(i, 8)) % mod;
		}
		System.out.println(ans);
	}
	
	static long quickPow(long a, int b) {
		long ans = 1;
		while(b > 0) {
			if((b & 1) == 1) ans = (ans * a) % mod;
			a = (a * a) % mod;
			b >>= 1;
		}
		return ans;
	}

}

在這裡插入圖片描述

import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		char[] a = s.toCharArray();
		boolean[] vis = new boolean[a.length];
		char[] ans = new char[a.length];
		int cnt = 0, tmp;
		for(int i = 0; i < a.length - 1; i ++) {
			tmp = (a[i] - '0') * 10 + a[i + 1] - '0';
			if(tmp <= 26) {
				ans[cnt ++] = (char)('A' + tmp - 1);
				vis[i] = vis[i + 1] = true;
				i ++;
			} else {
				ans[cnt ++] = (char)('A' + a[i] - '0' - 1);
				vis[i] = true;
			}
		}
		if(!vis[a.length - 1]) ans[cnt ++] = (char)('A' + a[a.length - 1] - '0' - 1);
		for(int i = 0; i < cnt; i ++) System.out.print(ans[i]);
	}

}

在這裡插入圖片描述
在這裡插入圖片描述
在這裡插入圖片描述
在這裡插入圖片描述