- 正方形逆时针走,
n
,m
,k
打印坐标
import java.util.Scanner; //AC public class Main_1 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double n=in.nextDouble();
int m=in.nextInt();
double r=in.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));
}
}
}
- 涂墙,改变颜色
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 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";
}
}
}
- 暴力题解,不会,据说这个思路可以
另外,我决定逐渐弃用C++,减少用Python, 增加 Scala, C语言和Go语言比例