蓝桥杯历年试题

蓝桥杯历年试题_第1张图片

import java.util.*;

class Main{
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		scan.close();
		int x=gcd(a,b);
		int num1=a*b/x;
		int y=gcd(num1,c);
		System.out.println(num1*c/y);
	}
	public static int gcd(int a,int b)
	{
		return b>0? gcd(b,a%b):a;
	}
}

蓝桥杯历年试题_第2张图片蓝桥杯历年试题_第3张图片

import java.util.*;

class Main{
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		scan.close();
		int len=4*n+5;
		int mid=len/2;
		char[][] x=new char[len][len];
		for(int i=0;i<=mid;i++)//左上三角
			{
				if(i==0||i==1)
				{
					for(int j=0;j<=i;j++)
						x[i][j]='.';
				}
				else 
				{
					for(int j=i;j>=0;j--)
					{
							if(j>=i-2)
							{
								if(i%2==0)
									x[i][j]='$';
								else
									x[i][j]='.';
							}
							else if(j%2==0)
								x[i][j]='$';
							else
								x[i][j]='.';
					}
				}
			}
		for(int i=0;i

蓝桥杯历年试题_第4张图片

import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args)
	{
		List a=new ArrayList();
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		String ss=scan.nextLine();//接受输入行数后的回车符
		for(int i=1;i<=n;i++)
		{
			String s=scan.nextLine();
			String[] b=s.split(" ");
			//System.out.println(b.length);
			int j=0;
			while(j!=b.length)
			{
				if(b[j]!="")
					a.add(Integer.parseInt(b[j]));
				j++;
			}
		}
		scan.close();
		Collections.sort(a);
		int start=a.get(0);
		int count=0,i=0;
		int rq=0,rc=0;
		while(count!=2)
		{
			if(a.get(i)==start+i)
			{
				i++;
				continue;
			}
			else if(a.get(i)>start+i)
			{
				rq=start+i;
				start+=1;
				count+=1;
			}
			else
			{
				rc=a.get(i);
				start-=1;
				count+=1;
			}
		}
		System.out.print(rq+" "+rc);
	}
}

蓝桥杯历年试题_第5张图片

import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args)
	{
		List a=new ArrayList<>();
		Scanner scan=new Scanner(System.in);
		String s1=scan.nextLine();
		String s2=scan.nextLine();
		for(int i=0;i

蓝桥杯历年试题_第6张图片

import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int[] a=new int[n+1];
		for(int i=1;i<=n;i++)
		{
			a[i]=scan.nextInt();
		}
		scan.close();
		int sum=0;
		for(int i=1;i<=n;i++)
		{
			int l=a[i],r=a[i];
			sum++;
			for(int j=i+1;j<=n;j++)
			{
				if(a[j]>r) r=a[j];
				if(a[j]

蓝桥杯历年试题_第7张图片

import java.io.*;
import java.util.*;

class Main{
	static int[][] a;
	static int n;
	static int sum=0;
	static int temp=0;
	static int vis=0;
	static int key=0;
	static List b=new ArrayList<>();
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		n=scan.nextInt();
		a=new int[n+1][n+1];
		for(int i=0;isum)
				{
					key=vis;
					sum=temp;
				}
				temp-=a[r][j];
			}
		}
		return;
	}
}

蓝桥杯历年试题_第8张图片

import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args)
	{
		String[] s= {"672159834","816357492","438951276","294753618",
              "276951438","618753294","834159672","492357816"
             };
		Scanner scan=new Scanner(System.in);
		String str="";
		for(int i=0;i<9;i++)
		{
			str=str+scan.nextInt();
		}
		scan.close();
		int num=0;
		int key=-1;
		//System.out.print(s);
		for(int i=0;i

蓝桥杯历年试题_第9张图片

import java.io.*;
import java.util.*;

class Main{
	static int root;
	static point[] tree=new point[10005];
	static class point{
		public int value;
		public int left;
		public int right;
		public int father;
		
		point() {
			this.value=0;
			this.left=0;
			this.right=0;
			this.father=0;
		}
	}
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		String s=scan.nextLine();
		scan.close();
		String[] ss=s.split(" ");
		root=Integer.parseInt(ss[0]);
		for(int i=0;itemp)
				{
					if(tree[temp].right==0)
					{
						tree[temp].right=a;
						tree[a].father=temp;
						break;
					}
					else
					{
						temp=tree[temp].right;
					}
				}
				else
				{
					if(tree[temp].left==0)
					{
						tree[temp].left=a;
						tree[a].father=temp;
						break;
					}
					else
					{
						temp=tree[temp].left;
					}
				}
			}
		}
		String s1="";
		String s2="";
		DFS(root,s1,0,s2);
	}
	static void DFS(int start,String s1,int n,String s2)
	{
		if(tree[start].value==root)
			s1=s1+tree[start].value;
		else {
			s1+="-|-";
			s1+=tree[start].value;
		}
		if(tree[start].right>0)
		{
			s2+="1";
			DFS(tree[start].right,s1,n+1,s2);
			s2=s2.substring(0,s2.length()-1);
		}
		int len = s1.length();
        int cot = 0;
        for(int i = 0;i < len;i++) {
            if(s1.charAt(i) == '|') {
                if(s2.length() <= cot + 1 || s2.charAt(cot) != s2.charAt(cot + 1))
                    System.out.print("|");
                else
                    System.out.print(".");
                cot++;
            } else if(cot < n) {
                System.out.print(".");
            } else {
                System.out.print(s1.charAt(i));
            }
        }
        if(tree[start].left > 0 || tree[start].right > 0)
            System.out.print("-|");
        System.out.println();
        if(tree[start].left > 0) {
            s2 = s2 + "0";
            DFS(tree[start].left, s1, n + 1, s2);
            s2 = s2.substring(0, s2.length() - 1);
        }
	}
}

蓝桥杯历年试题_第10张图片

import java.io.*;
import java.util.*;

class Main{
	static boolean[][] know;
	static int[][] examRoom;
	static int n;
	static int res=101;//记录最小的考场数
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		n=scan.nextInt();
		know=new boolean[n+1][n+1];
		examRoom=new int[n][n+1];
		int m=scan.nextInt();
		for(int i=0;i=res) return;
		//考生编号大于考生人数,分配完了
		if(id>n) {
			res=Math.min(numRoom, res);
			return;
		}
		//判断分配了的考场中考生是否认识
		A:for(int i=0;i

蓝桥杯历年试题_第11张图片

import java.io.*;
import java.util.*;

class Main{ 
	static boolean[][] vis=new boolean[10005][10005];
	static int sum=0;
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		for(int i=0;i

你可能感兴趣的:(蓝桥杯,蓝桥杯,历年试题,试题集)