头像

rjqc




离线:11小时前


最近来访(37)
用户头像
xbor
用户头像
天后
用户头像
Faltings_7
用户头像
815741912
用户头像
marksiz
用户头像
kelvin2009
用户头像
秘封の月列
用户头像
吉尔伽美什
用户头像
NFTB
用户头像
老邪
用户头像
Payxtl
用户头像
xiuzhiyuan
用户头像
与氧存
用户头像
shark_big
用户头像
Negan_0
用户头像
想请你陪我无聊
用户头像
放弃最轻松
用户头像
Hyperspace
用户头像
有风来i
用户头像
zztt

活动打卡代码 AcWing 769. 替换字符

rjqc
11小时前
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        char a=sc.next().charAt(0);
        char c[]=s.toCharArray();
        for(var x:c) 
            if(x==a) System.out.print('#');
            else System.out.print(x);
    }
}




活动打卡代码 AcWing 765. 字符串加空格

rjqc
12小时前
import java.util.*;

public class Main{
    public static void main(String[] args)
    {
        Scanner sc =new Scanner(System.in);
        String str=sc.nextLine();
        char c[]=str.toCharArray();
        for(var x:c)  System.out.print(x+" ");
    }
}


活动打卡代码 AcWing 1113. 红与黑

rjqc
12小时前

```
bfs

include[HTML_REMOVED]

include[HTML_REMOVED]

include[HTML_REMOVED]

define x first

define y second

using namespace std;
const int N=25,M=N*N;
typedef pair[HTML_REMOVED] PII;
int n,m;
char g[N][N];
bool st[N][N];
PII q[M];
int x,y;
int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
int bfs(int x,int y)
{
int area=0;
int hh=0,tt=0;
q[0]={x,y};
st[x][y]=true;
while(hh<=tt)
{
PII t=q[hh];
area
;
for(int i=0;i<4;i)
{
int a=t.x+dx[i],b=t.y+dy[i];
if(a<0||a>=n||b<0||b>=m) continue;
if(g[a][b]==’#’) continue;
if(st[a][b]) continue;
q[
tt]={a,b};
st[a][b]=true;
}
}
return area;
}
int main()
{
while(cin>>m>>n,n||m)
{
memset(st,0,sizeof st);
for(int i=0;i<n;i) scanf(“%s”,g[i]);
int x,y,flag=0;
for(int i=0;i<n;i
)
{
for(int j=0;j<m;j++)
if(g[i][j]==’@’)
{
x=i,y=j;
flag=1;
}
if(flag) break;
}
cout<< bfs(x,y) <<endl;
}
return 0;
}
···



活动打卡代码 AcWing 1112. 迷宫

rjqc
21小时前
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 110;

int n;
char g[N][N];
int xa, ya, xb, yb;
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
bool st[N][N];

bool dfs(int x, int y)
{
    if (g[x][y] == '#') return false;
    if (x == xb && y == yb) return true;

    st[x][y] = true;

    for (int i = 0; i < 4; i ++ )
    {
        int a = x + dx[i], b = y + dy[i];
        if (a < 0 || a >= n || b < 0 || b >= n) continue;
        if (st[a][b]) continue;
        if (dfs(a, b)) return true;
    }

    return false;
}

int main()
{
    int T;
    scanf("%d", &T);
    while (T -- )
    {
        scanf("%d", &n);
        for (int i = 0; i < n; i ++ ) scanf("%s", g[i]);
        scanf("%d%d%d%d", &xa, &ya, &xb, &yb);

        memset(st, 0, sizeof st);
        if (dfs(xa, ya)) puts("YES");
        else puts("NO");
    }

    return 0;
}


活动打卡代码 AcWing 763. 循环相克令

rjqc
22小时前
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);

        int n=sc.nextInt();

        while(n -- >0){
            String player1=sc.next();
            String player2=sc.next();

            if(player1.equals(player2)){
                System.out.println("Tie");
            }else{
                if("Hunter".equals(player1) && "Gun".equals(player2)){
                    System.out.println("Player1");
                }else if("Bear".equals(player1) && "Gun".equals(player2)){
                    System.out.println("Player2");
                }else if("Hunter".equals(player1) && "Bear".equals(player2)){
                    System.out.println("Player2");
                }else if("Bear".equals(player1) && "Hunter".equals(player2)){
                    System.out.println("Player1");
                }else if("Gun".equals(player1) && "Hunter".equals(player2)){
                    System.out.println("Player2");
                }else if("Gun".equals(player1) && "Bear".equals(player2)){
                    System.out.println("Player1");
                }
            }
        }
    }
}




rjqc
22小时前
import java.util.Scanner;

public class Main{

    public static void main(String[] args)
    {
        Scanner sc =new Scanner(System.in);
        String str = sc.nextLine();
        char c[]=str.toCharArray();
        int sum=0;
        for(var x:c)
        {
            if(x>='0'&&x<='9')
            sum++;
        }
        System.out.println(sum);
    }
}


活动打卡代码 AcWing 760. 字符串长度

rjqc
22小时前
import java.util.Scanner;

public class Main{

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        System.out.println(str.length());
    }
}


活动打卡代码 AcWing 4618. 两个素数

rjqc
3天前
#include <bits/stdc++.h>
#define i32 int
#define i64 long long
#define x first
#define y second

using namespace std;
typedef pair<int,int> PII;

int T,n,x,y,m;

int main ()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i=2;i<=n;i++) {
        if (n%i==0) {
            cout<<i<<' '<<n/i;
            break;
        }
    }
    return 0;
}



活动打卡代码 AcWing 756. 蛇形矩阵

rjqc
4天前

import java.util.*;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

    int n = sc.nextInt(), m = sc.nextInt();
    int[][] q = new int[n][m];
    int[] dx = {-1, 0, 1, 0}, dy = {0, 1, 0, -1};
    int d = 1, x = 0, y = 0;

    for (int i = 1; i <= n * m; i ++ ) {
        q[x][y] = i;
        int a = x + dx[d], b = y + dy[d];
        if (a < 0 || a >= n || b < 0 || b >= m || q[a][b] > 0) {
            d = (d + 1) % 4;
            a = x + dx[d];
            b = y + dy[d];
        }
        x = a;
        y = b;
    }

    for (int i = 0; i < n; i ++ ) {
        for (int j = 0; j < m; j ++ ) {
            System.out.printf("%d ", q[i][j]);
        }
        System.out.println();
    }
}

}



活动打卡代码 AcWing 755. 平方矩阵 III

rjqc
4天前
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        int n;
        while((n=sc.nextInt())>0)
        {
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<n;j++)
                System.out.print((1<<(i+j))+" ");
                System.out.println("");
            }
            System.out.println("");
        }
    }
}