快手笔试2019/8/25

岗位:

秋招:一共4到笔试

ac:100 0 100 100

题目全没保存。。。。。(有空再补)

1、

import java.util.Scanner;

public class First {

	public static void main(String[] args) {
		Scanner sc = new  Scanner(System.in);
		int m = sc.nextInt();
		sc.nextLine();
		for(int i = 0; i < m; i++) {
			String string = sc.nextLine();
			String[] split = string.split(" ");
			
			int a = 0,b = 0;
			
			String[] aString = split[0].split("\\.");
			int count = 3;
			for(int j = 0; j < aString.length; j++) {
				a += Integer.parseInt(aString[j]) * Math.pow(100, count--);
			}
			
			String[] bString = split[1].split("\\.");
			count = 3;
			for(int j = 0; j < bString.length; j++) {
				b += Integer.parseInt(bString[j]) * Math.pow(100, count--);
			}
			
			if(b > a) {
				System.out.println(true);
			} else {
				System.out.println(false);
			}
			
		}
	}
	
}

2、

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class Fourth {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[][] array = new int[n - 1][3];
		int red = 0,black = 0;
		for(int i = 0; i < n - 1; i++) {
			array[i][0] = sc.nextInt();
			array[i][1] = sc.nextInt();
			array[i][2] = sc.nextInt();
			
			if(array[i][2] == 0) {
				red++;
			} else {
				black++;
			}
			
		}
		
		if(red == 0) {
			System.out.println((int)((Math.pow(n, k) - n) % 1000000007));
		} else if(black == 0) {
			System.out.println(0);
		} else {
			/*int count = (int)(Math.pow(n, k) % 1000000007);
			
			System.out.println((int)(count - Math.pow(red + 1,k) - black));*/
			
			//红表示可以连通,黑表示不可以连通,求连通图个数和每个连通图的数量
            
            //然后n^k减连通图元素个数^k的和再减黑色节点个数就是答案
            
            //没时间实现类,难受。。。。。。。。。。。。。。
			HashSet<ArrayList<Integer>> set = new HashSet<ArrayList<Integer>>();
			
			
		}
		
		
		
	}
	
}

3、

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Second {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int temp;
		for(int i = 0; i < n; i++) {
			temp = sc.nextInt();
			if(judge(temp)) {
				System.out.println(true);
			} else {
				System.out.println(false);
			}
		}
	}
	
	public static boolean judge(int number) {
		
		Set<Integer> set = new HashSet<Integer>();
		
		int temp,a;
		while(true) {
			temp = 0;
			//计算各个位数的平方
			String[] split = new String(number + "").split("");
			
			for(int i = 0; i < split.length;i++) {
				a = Integer.parseInt(split[i]);
				temp += a * a;
			}
			
			if(temp == 1) {
				return true;
			}
			
			if(set.contains(temp)) {
				break;
			} else {
				set.add(temp);
				number = temp;
			}
		}
		
		return false;
	}
	
}

4、

import java.util.Scanner;

public class Third {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String string1 = sc.nextLine();
		String string2 = sc.nextLine();
		String[] split1 = string1.split(" ");
		String[] split2 = string2.split(" ");
		
		int j = 0;
		
		for(int i = 0; i < split1.length; i++) {
			if((i + 1) % 4 == 0) {
				System.out.print(split1[i] + " ");
				if(j < split2.length) {
					System.out.print(split2[j++] + " ");
				}
			} else {
				System.out.print(split1[i] + " ");
			}
		}
		
		for(; j < split2.length; j++) {
			System.out.print(split2[j] + " ");
		}
		
		
	}
	
}

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值