同程笔试程序代码

题目1:
package org.example.tc;
import java.util.Scanner;

public class main1 {
    public static int mod=1000000007;
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int m = in.nextInt();
            int ou =0;
            int ji=0;
            long  v=0;
            if(m%2==0){
                ji=m/2;
                ou=m/2;
            }else{
                ji=m/2+1;
                ou=m/2;
            }
            ji%=mod;
            ou%=mod;
            long  ans=ji;
            for(int i=2;i<=n;i++){
                if(i%2==0){
                    ans=((ans%mod)*(ou%mod))%mod;

                }else{
                    ans=((ans%mod)*(ji%mod))%mod;

                }
            }
            System.out.println(ans);

        }

}
题目2

package org.example.tc;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main2 {

    public static String t1 = &quot;registration complete&quot;;
    public static String t2 = &quot;illegal length&quot;;
    public static String t3 = &quot;acount existed&quot;;
    public static String t4 = &quot;illegal charactor&quot;;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        Set<String> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            String s = in.nextLine();
            if (set.contains(s)) {
                System.out.println(t3);
            } else if (s.length() < 6 || s.length() > 12) {
                System.out.println(t2);
            } else if (judge(s)) {
                set.add(s);
                System.out.println(t1);
            }
        }
    }
 public static boolean judge(String s) {
        char c []=s.toCharArray();
        for(int i=0;i<c.length;){
            if((c[i]>='a'&amp;&amp;c[i]<='z')){
                i++;
            }else if(c[i]>='A'&amp;&amp;c[i]<='Z'){
                i++;
            }else {
                System.out.println(t4);
                return false;
            }

        }
        return true;
    }
 }
#牛客创作赏金赛##软件开发笔面经##软件开发投递记录#
全部评论

相关推荐

07-11 22:27
中南大学 Java
程序员牛肉:学历的话没问题。但是没问题的也就只有学历了。 其实你的整体架构是正确的,博客接着干。但是项目有点过于简单了。从后端的角度上讲,你这也就是刚入门的水平,所以肯定约面试够呛。 如果你要应聘后端岗位,那你第一个项目竟然是仿写操作系统。这个你要面试官咋问你。你一定要记住一点,你简历上写的所有的东西,都是为了证明你有能力胜任当前的岗位,而不是为了证明你自己会什么。 如果你只是浅浅的做几个项目,描述也都是烂大街。技术点也都是各种混水类的配置类需求,那你就不要幻想自己能走多远。一定要保持思考,保持学习。
点赞 评论 收藏
分享
评论
4
1
分享

创作者周榜

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