同程笔试程序代码
题目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 = "registration complete";
public static String t2 = "illegal length";
public static String t3 = "acount existed";
public static String t4 = "illegal charactor";
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long n = in.nextLong();
Set 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 if((c[i]>='a'&&c[i]<='z')){
i++;
}else if(c[i]>='A'&&c[i]<='Z'){
i++;
}else {
System.out.println(t4);
return false;
}
}
return true;
}
}
#牛客创作赏金赛##软件开发笔面经##软件开发投递记录#
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 = "registration complete";
public static String t2 = "illegal length";
public static String t3 = "acount existed";
public static String t4 = "illegal charactor";
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long n = in.nextLong();
Set
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
i++;
}else if(c[i]>='A'&&c[i]<='Z'){
i++;
}else {
System.out.println(t4);
return false;
}
}
return true;
}
}
#牛客创作赏金赛##软件开发笔面经##软件开发投递记录#
全部评论
相关推荐
10-14 15:51
门头沟学院 Java 点赞 评论 收藏
分享