牛客小白赛17
基本上签到题(┭┮﹏┭┮ , 手动暂停。。。。)
B题 扫雷(暴力)
#include <cstdio>
const int N = 105 ;
int main(){
int n , m ;
char ch[N][N] ;
scanf ("%d%d",&n,&m) ;
for (int i = 0 ; i < n ; i ++)
scanf("%s",ch[i]) ;
for (int i = 0 ; i < n ; i ++){
for (int j = 0 ; j < m ; j ++){
int count = 0 ;
if (ch[i][j] == '*')
printf ("*") ;
else{
for (int x = i-1 ; x >= x+1 ; x ++){
for (int y = j-1 ; y >= j+1 ; y ++){
if (x>=0&&x<n && y>=0&&y<m){
if (ch[i][j] == '*')
count ++ ;
}
}
}
printf ("%d",count) ;
}
}
printf ("\n") ;
}
return 0 ;
}
C题 异或和(水题)
出现次数为偶数则两两异或抵消。
#include <cstdio>
int main(){
int n , ans , x ;
scanf("%d",&n) ;
for (int i = 1 ; i <= n ; i ++){
scanf ("%d",&x) ;
ans ^= x ;
}
printf ("%d\n",ans) ;
return 0 ;
}
G题 区间求和:莫队算法(链接:https://blog.youkuaiyun.com/coder370/article/details/101164360)
I题 坐电梯
#include <cstdio>
int n , k ;
int main(){
scanf ("%d%d",&n,&k) ;
int max = 0 , x ;
for (int i = 0 ; i < n ; i ++){
scanf ("%d",&x) ;
if (x > max) max = x ;
}
int ans = max-1 + max - k ;
printf ("%d\n",ans) ;
return 0 ;
}
1374

被折叠的 条评论
为什么被折叠?



