Question number: | 201412-1 |
Question name: | Access control system |
time limit: | 1.0s |
Memory limit: | 256.0MB |
Problem Description: | Problem Description Taotao is currently responsible for the management of the library and needs to record the visits of readers every day. Each reader has a number, and each record is represented by the reader's number. Given the visit records of the readers, ask how many times the readers in each record appeared. Input format The first line of input contains an integer n, which represents the number of Taotao records. Output format Output a line, containing n integers, separated by spaces, indicating in turn how many times the reader number in each record appears. Sample input 5 Sample output 1 1 2 3 1 Evaluation use case scale and conventions 1≤n≤1,000, the reader's number is a positive integer not exceeding n. |
import java.util.Scanner;
public class 门禁系统201412_1 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int total=sc.nextInt();
int[] a=new int[1001];
int[] res=new int[total+1];
for(int i=1;i<=total;i++){
int per=sc.nextInt();
a[per]+=1;
res[i]=a[per];
}
for(int i=1;i<=total;i++){
System.out.print(res[i]+" ");
}
System.out.println();
}
}
Question number: | 201503-1 |
Question name: | Image rotation |
time limit: | 5.0s |
Memory limit: | 256.0MB |
Problem Description: | Problem Description Rotation is the basic operation of image processing. In this problem, you need to rotate an image 90 degrees counterclockwise. Input format The first line of input contains two integers n and m , which represent the number of rows and columns of the image matrix, respectively. Each of the Output format Output m rows, each row contains n integers, representing the original matrix rotated 90 degrees counterclockwise. Sample input 2 3 Sample output 3 4 评测用例规模与约定 1 ≤ n, m ≤ 1,000,矩阵中的数都是不超过1000的非负整数。 |
我的内存超范围了 只有90分 等刷到100分我再更新代码
import java.util.Scanner;
public class 图像旋转201503_1 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
// int[][] a=new int[n+1][m+1];
// for(int i=1;i<=n;i++){
// for(int j=1;j<=m;j++){
// a[i][j]=sc.nextInt();
// }
// }
// for(int j=m;j>=1;j--){
// for(int i=1;i<=n;i++){
// System.out.print(a[i][j]+" ");
// }
// System.out.println();
// }
int[] a=new int[n*m+1];
for(int i=1;i<=n*m;i++){
a[i]=sc.nextInt();
}
for(int j=0;j<m;j++){
for(int i=1;i<=n;i++){
System.out.print(a[m*i-j]+" ");
}
System.out.println();
}
// long memory =Runtime.getRuntime().totalMemory();
// System.out.println(memory);
}
}