1.AC
import java.util.Scanner;
public class tt {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int c = sc.nextInt();
int[] arr = new int[n];
for (int i=0; i<n; i++){
arr[i] = sc.nextInt();
}
for(int i = 0; i<n;i++){
int target = arr[i] - 1;
int index = target/c;
int order = target%c+1;
char res = (char)('A'+index);
System.out.println(res+""+order);
}
}
}
2. 91%
在这里插入图片描述
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner a=new Scanner(System.in);
String m=a.nextLine();
int len=m.length();
int num=Integer.parseInt(a.nextLine());
int [] nums=new int [len];
for(int i=0;i<len;i++){
nums[i] = m.charAt(i)-'a';
}
for(int i=0;i<num;i++){
String [] strs= a.nextLine().split(" ");
int x= Integer.parseInt(strs[0]);
int y=Integer.parseInt(strs[1]);
int k=Integer.parseInt(strs[2]);
for(int j=x-1;j<=y-1;j++){
nums[j]-=(k%26);
if(nums[j]<0) nums[j]+=26;
}
}
StringBuilder res=new StringBuilder();
for(int i=0;i<len;i++){
char temp= (char) ('a'+nums[i]);
res.append(temp);
}
System.out.println(res.toString());
}
}
//abcdefg
//3
//1 3 79
//2 4 79
//3 5 80
//
// zzyacfg
3. AC
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int G = sc.nextInt();
for (int i = 0; i<G; i++){
int n = sc.nextInt();
int[] arr = new int[n];
for (int j = 0; j<n; j++){
arr[j] = sc.nextInt();
}
int[] res = func(arr);
if (res[2] == 0){
System.out.println(0);
}
else if (res[2] == -1){
System.out.println(-1);
}
else{
System.out.println(res[0] + " " + res[1] + " " + res[2]);
}
}
}
public static int[] func(int[] arr){
int[] res = new int[3];
int L = -1;
int R = arr.length;
for (int i = 0; i<arr.length; i++){
if (arr[i] == i+1){
L++;
}
else{
break;
}
}
for (int i = arr.length-1; i>=L; i--){
if (arr[i] == i+1){
R--;
}
else{
break;
}
}
if (L == R){
return res;
}
res[0] = L+2;
res[1] = R;
int L2 = L+1;
for (int i = L+1; i<R; i++){
if (arr[i]+1 == arr[i+1]){
L2++;
}
else{
break;
}
}
int R2 = L2+1;
for (int i = L2+1; i<R-1; i++){
if (arr[i]+1 == arr[i+1]){
R2++;
}
else{
break;
}
}
if (R2 +1 == R){
res[2] = L2-L;
return res;
}
res[2] = -1;
return res;
}
}
4. 82%
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int countRect(vector<string> &grid, int x, int y, int n) {
int cnt = 0;
int limit = n;
for (int i = x; i < n; ++i) {
for (int j = y; j < limit; ++j) {
if (grid[i][j] == '.') ++cnt;
else {
limit = j;
break;
}
}
}
return cnt;
}
int main() {
int n;
cin >> n;
vector<string> grid(n);
for (int i = 0; i < n; i++) {
cin >> grid[i];
}
int ret = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (grid[i][j] == '.') {
ret += countRect(grid, i, j, n);
}
}
}
cout << ret;
return 0;
}