题解 | 牛客小白月赛88 DEFG

超级闪光牛可乐

https://ac.nowcoder.com/acm/contest/75771/A

未完待续。。

D我不是大富翁

import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt(),m=sc.nextInt();
        boolean has[]=new boolean[n];
        has[0]=true;
        for(int i=0;i<m;i++){
            boolean ok[]=new boolean[n];
            int a=sc.nextInt()%n;
            for(int j=0;j<n;j++){
                if(has[j]){
                    ok[(j+a)%n]=true;
                    ok[(j+n-a)%n]=true;
                }
            }
            has=ok;
        }
        System.out.println(has[0]?"YES":"NO");
    }
}

E多重映射

import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        for(int i=0;i<t;i++){
            int n=sc.nextInt(),m=sc.nextInt(),xy[][]=new int[m][],a[]=new int[n];
            for(int j=0;j<n;j++){
                a[j]=sc.nextInt();
            }
            for(int j=0;j<m;j++){
                xy[j]=new int[]{sc.nextInt(),sc.nextInt()};
            }
            Map<Integer,Integer> map=new HashMap<>();
            for(int j=m-1;j>=0;j--){
                if(map.containsKey(xy[j][1])){
                    map.put(xy[j][0],map.get(xy[j][1]));
                }
                else{
                    map.put(xy[j][0],xy[j][1]);
                }
            }
            for(int b:a){
                System.out.print(map.getOrDefault(b,b)+" ");
            }
            System.out.println();
        }
    }
}

F现在是消消乐时间

import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt(),m=sc.nextInt(),d=sc.nextInt();
        if(check(n,m,d,0,0,new int[]{1,1})){
            System.out.println("yes\n0 0\nUR");
        }
        else if(check(n,m,d,1,0,new int[]{-1,1})){
            System.out.println("yes\n1 0\nDR");
        }
        else{
            System.out.println("no");
        }
    }
    static boolean check(int n,int m,int d,int a,int b,int dir[]){
        int count[][]=new int[n][m];
        while(true){
            int x=a+dir[0],y=b+dir[1];
            if(x<0||x>n||y<0||y>m){
                dir[0]*=-1;
                for(int i=-1;i<=1;i+=2){
                    x=a+dir[0]*i;
                    y=b+dir[1]*i;
                    if(x>=0&&x<=n&&y>=0&&y<=m){
                        dir[0]*=i;
                        dir[1]*=i;
                        break;
                    }
                }
            }
            if(count[(a+x)/2][(b+y)/2]==2){
                break;
            }
            count[(a+x)/2][(b+y)/2]++;
            if((x==0||x==n)&&(y==0||y==m)){
                break;
            }
            a=x;
            b=y;
        }
        for(int i=d;i<n;i++){
            for(int j=0;j<m;j++){
                if(count[i][j]==0){
                    return false;
                }
            }
        }
        return true;
    }
}

G三点不贡献

import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        for(int i=0;i<t;i++){
            int x1=sc.nextInt(),y1=sc.nextInt(),x2=sc.nextInt(),y2=sc.nextInt();
            double a=sc.nextInt()*Math.PI/180;
            int dir[]=new int[]{x2-x1,y2-y1};//向量ab
            double hypo[]=new double[]{dir[0]*Math.sin(a/2)-dir[1]*Math.cos(a/2),dir[0]*Math.cos(a/2)+dir[1]*Math.sin(a/2)};//ab旋转
            hypo[0]/=Math.sin(a/2)*2;
            hypo[1]/=Math.sin(a/2)*2;
            System.out.println(x1+hypo[0]+" "+(y1+hypo[1]));
        }
    }
}
全部评论

相关推荐

有很多问题,求大佬们解答,谢谢大佬们:不知道现在该怎么投实习,该怎么准备内心很纠结学校课程和实习到底怎么选择,&nbsp;自己也不想课程学业这边出问题,&nbsp;是不是只能投暑期实习,具体时间该怎么安排前端面试也需要准备算法么,&nbsp;自己的算法能力很薄弱,&nbsp;面试题需要准备到什么程度?没有ai项目经验的话,我该如何去补充,如何去找好的ai项目
smile丶snow:1.简历尽量一页,比如教育经历那里,全日制,计算机学院这些可以去掉没啥用好浪费空间。 熟悉三件套就没必要写了吧。js基本上是这样写 * JavaScript核心:深入理解 JS 运行机制(事件循环 Event Loop、微任务/宏任务),熟练掌握 Promise/Async 异步编程 模型。 熟悉可以改成熟练掌握。组件库写一个ant感觉就行,多写了浪费空间。 旅游项目是不是jonas的natours啊,我之前简历也有这个。我之前是这样写的 全栈思维: 熟悉 Node.js/Express 后端架构,掌握 MongoDB 数据库设计与聚合查询 工程化我觉得还是少些吧,不写就问的少,如果你真的了解的话可以写。 1.实习的话推荐大厂官网和aoob上面投,我自己有写一个校招网站的小网站可以直达~github主页上面有,顺便求个关注( 2.大三下一般课程比较少了吧,如果学校比较严的话可以多沉淀一会,如果不太严可以请dai课然后去实习,尽量找个近一些的就行。暑期实习不是暑假才实习哦,基本是上3月底4月初发offer就可以过去了,然后大概暑假的时候走转正流程答辩。 3.大厂算法题+js手写体。hot100+常见的比如数组转树,Promise.all,deepClone,之类 js手写都不难其实。算法看自己能力吧,我其实算法能力也不行。 4.自己平时没有用AI Coding吗?自己想一下怎么让AI帮你更好的写代码~比如Skill的诞生,OpenSpec的诞生,不都是我们想让AI更好帮我们写代码吗。
我的实习日记
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务