第1题Java题解
import java.util.Scanner; //AC public class Main_1 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
double n=sc.nextDouble();
int m=sc.nextInt();
double r=sc.nextDouble();
double x=0;
double y=0;
double count=0;
while (m-->0){
count+=r;
double left=count%n;
int round= (int) (count/n)%4;
switch (round){
case 0:x=left;y=0;break;
case 1:x=n;y=left;break;
case 2:x=n-left;y=n;break;
case 3:x=0;y=n-left;break;
}
System.out.println(String.format("%.2f",x)+" "+String.format("%.2f",y));
}
}
}
第2题Java题解
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
//AC
public class Main_2 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int T=sc.nextInt();
while (T-->0){
int n=sc.nextInt();
int a[]=new int[n];
int b[]=new int[n];
for (int i = 0; i < n; i++) {
a[i]=sc.nextInt();
}
for (int i = 0; i < n; i++) {
b[i]=sc.nextInt();
}
System.out.println(isValid(a,b));
}
}
public static String isValid(int a[], int b[]){
int n=a.length;
Map<Integer,Integer> map=new HashMap<>();
for (int i = 0; i < n; i++) {
map.put(a[i],i);
}
int count=1;
for (int i = 1; i < n; i++) {
if(map.get(b[i])>=map.get(b[i-1])){
count++;
}
}
if(count==n){
return "YES";
}else{
return "NO";
}
}
}
第3题Java题解(抱歉,太菜了,搞了半个小时没弄出来~),诚招AC题解
#VMware##笔试题目#