小学数学题
第二题
纯模拟,首先要有分组的概念
例如样例:
4 3 2
第一组 第二组 第三组 第四组
第一组 . . # # . . # #
. . # # . . # #
. . # # . . # #
第二组 # # . . # # . .
# # . . # # . .
# # . . # # . .
第三组 . . # # . . # #
. . # # . . # #
. . # # . . # #
第四组 # # . . # # . .
# # . . # # . .
# # . . # # . .
现在只需判断一下奇偶性即可
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int main(){
scanf("%d%d%d",&n,&a,&b);
for(int i=1;i<=n*a;i++){
for(int j=1;j<=n*b;j++){
int team_i=int(ceil(i*1.0/a));//行的队伍
int team_j=int(ceil(j*1.0/b));//列的队伍
if(team_i%2==1){//奇偶性讨论分析
if(team_j%2==1) printf(".");
else printf("#");
}else{
if(team_j%2==0) printf(".");
else printf("#");
}
}
printf("\n");
}
return 0;
}