刷题记录4-11
洛谷题单 2023 官方题单(1~4 月)
轴对称
把YES和Yes搞混了一直过不去……然后忘了多维数组在函数怎么定义为参数了。
#include<stdio.h>
//多维数组定义为参数的时候,要写为int jpg[100][100][3]
//注意输出格式是Yes还是YES
void check(int jpg[100][100][3],int n,int m){
int flag;
for(int x=0;x<n;x++){
for(int y=0;y<m;y++){
for(int z=0;z<3;z++){
flag = jpg[x][y][z]==jpg[x][m-y-1][z];
if (!flag){
printf("No\n");
return;
}
}
}
}
printf("Yes\n");
return;
}
void print_x_y(int jpg[100][100][3],int n,int m){
for(int x=0;x<n;x++){
for(int y=0;y<m;y++){
for(int z=0;z<3;z++){
printf("%d,",jpg[x][y][z]);
}
printf(" ");
}
printf("\n");
}
}
int main(){
int m,n,q,i,j,t,c;
int jpg[100][100][3];
for(int x=0;x<100;x++){
for(int y=0;y<100;y++){
for(int z=0;z<3;z++){
jpg[x][y][z]=0;
}
}
}
scanf("%d %d %d", &n, &m, &q);
for(int x=0;x<q;x++){
scanf("%d %d %d %d", &i, &j, &t, &c);
i-=1;
j-=1;
t-=1;
jpg[i][j][t] += c;
if(jpg[i][j][t]>255){
jpg[i][j][t] = jpg[i][j][t]%256;
}
//print_x_y(jpg,n,m);
check(jpg,n,m);
}
return 0;
}
糖果
纯纯的数学题,没啥错误。
#include<stdio.h>
int main(){
int n,k;
scanf("%d %d", &n, &k);
int x;
x = k - (n%k);
printf("%d\n",x);
return 0;
}