2022-08-06美团后端Java笔试

题目解题讨论
差不多都是easy和medium难度
//Q5
import java.util.*;

public class Main
{
    static StringBuilder str = new StringBuilder("MeiTuannauTieMwow");
    static final int len = 17;
    public static void main(String args[])
    {
        Scanner cin = new Scanner(System.in);
        int times = cin.nextInt();
        for(int i = 0 ; i < times ; ++i)
        {
            long a = cin.nextLong();
            int t = get(a);
            switch(t){
                case -1:
                case -3:
                    System.out.println('w');
                    break;
                case -2:
                    System.out.println('o');
                    break;
                default:
                    System.out.println(str.charAt(t));
            }

        }
    }
    public static int get(long u){
        long temp = 0;
        int index = 0;
        while(temp < u){
            temp = (long)Math.pow(2,index) * 10 - 3;
            index++;
        }
        if(temp - u <= 2){
            return (int)(u - temp - 1);
        }
        return get(u - 2 *(u - (temp - 3) / 2 - 1));
    }
}


#美团##秋招##校招##投票#
全部评论
题目不是很难,注意细节 笔试第一次AK😀
点赞 回复 分享
发布于 2022-08-06 11:55

相关推荐

点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务