首页 > 网易云音乐 Android开发 笔经
头像
无情的offer收割机
编辑于 2020-08-16 08:46
+ 关注

网易云音乐 Android开发 笔经

2020.08.08 下午 笔试 1h40min

1)关键词

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double cnt = ((double) n) * 0.01;
        Map<String, Integer> map = new HashMap<>();
        Set<String> set = new HashSet<>();
        for(int i = 0; i < n; i++){
            String str = sc.nextLine();
            if(set.contains(str)) {
                continue;
            }

            if(!map.containsKey(str)) {
                map.put(str, 1);
            } else {
                map.put(str, map.get(str) + 1);
            }

            if((double) map.get(str) >= cnt) {
                set.add(str);
            }
        }

        System.out.println(set.size());
    }
}


2)牛牛铺地毯

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[] a = new int[t];
        int max = 0;
        for (int i = 0; i < t; i++) {
            a[i] = sc.nextInt();
            max = Math.max(max, a[i]);
        }

        if(max == 1) {
            for (int i = 0; i < t; i++) {
                System.out.println(1);
            }
            return;
        }

        int[] dp = new int[max + 1];
        dp[0] = 1;
        dp[1] = 1;
        dp[2] = 2;
        for (int j = 3; j <= max; j++) {
            dp[j] = (dp[j - 1] + dp[j - 2] + dp[j - 3]) % 10007;
        }

        for(int n : a) {
            System.out.println(dp[n]);
        }
    }
}


第一题90%,第三题100%,第二题不会做,第四题不会做。

全部评论

(3) 回帖
加载中...
话题 回帖

推荐话题

相关热帖

近期热帖

历年真题 真题热练榜 24小时
技术(软件)/信息技术类
查看全部

近期精华帖

热门推荐