蓝桥刷题
1.
长草
#include <iostream>
#include <queue>
#include <utility>
using namespace std;
int n, m;
int main(){
cin >> n >> m;
char arr[n+2][m+2];
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= m; ++j){
cin >> arr[i][j];
}
}
int k;
cin >> k;
queue<pair<int, int>> Q;
while(k > 0){
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= m; ++j){
if(arr[i][j] == 'g'){
pair<int, int> temp(i, j);
Q.push(temp);
}
}
}
while(!Q.empty()){
int x = Q.front().first;
int y = Q.front().second;
Q.pop();
arr[x - 1][y] = 'g';
arr[x + 1][y] = 'g';
arr[x][y - 1] = 'g';
arr[x][y + 1] = 'g';
}
--k;
}
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= m; ++j){
cout << arr[i][j];
}
cout << endl;
}
return 0;
}
2.
美丽的2
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
// 请在此输入您的代码
int count=0;
int temp;
for(int i=1;i<=2020;i++)
{
temp=i;
while(temp)
{
if(temp%10==2)
{
count++;
break;
}
temp=temp/10;
}
}
printf("%d",count);
return 0;
}
3.
阶乘约数
#include <iostream>
using namespace std;
#define int long long
const int N=1005;
int arr[N];
bool temp(int num)
{
for(int i=2;i<num;i++)
{
if(num/i==0)
{
return false;
}
}
return true;
}
signed main()
{
for(int i=1;i<=100;i++)
{
int num=i;
for(int j=2;j<=i;j++)
{
if(i%j==0)
{
int an=0;
if(temp[j])
{
while(num%j==0)
{
num/=j;
an++;
}
}
arr[j]+=an;
}
}
}
int ans=1;
for(int i=1;i<=100;i++)
{
arr[i]++;
ans*=arr[i];
}
cout<<ans;
return 0;
}