头像

天乔巴夏丶




在线 



import java.util.*;

class Main{

    static int[] nums;
    static int n , m;

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        nums = new int[n];
        for(int i = 0; i < n; i ++) nums[i] = sc.nextInt();

        System.out.printf("%.2f", solve());

    }
    static double solve(){
        double l = 0, r = 1e9;
        while(r - l > 1e-3){
            double mid = l + (r - l) / 2;
            if(check(mid)) l =  mid;
            else r = mid;
        }
        return l;
    }

    static boolean check(double len){
        int res = 0;
        for(int i = 0; i < n; i ++){
            res += nums[i] / len;
            if(res >= m) return true;
        }
        return false;
    }
}





import java.util.Scanner;

/**
 * @author Summerday
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // k进制
        int k = sc.nextInt();
        // 1 - 300 枚举一下
        for (int num = 1; num <= 300; num++) {

            String res = base(num * num, k);
            if (isValid(res)) {
                System.out.println(base(num, k) + " " + res);
            }

        }
    }

    // 求num的k进制表示
    private static String base(int num, int k) {
        StringBuilder res = new StringBuilder();
        while (num > 0) {
            res.append(get(num % k));
            num /= k;
        }
        return res.reverse().toString();
    }

    private static char get(int x) {
        if (x <= 9) return (char) (x + '0');
        return (char) (x - 10 + 'A');
    }

    // 判断是否为回文串
    private static boolean isValid(String num) {
        char[] chs = num.toCharArray();
        int i = 0, j = chs.length - 1;
        while (i < j) {
            if (chs[i] != chs[j]) return false;
            i++;
            j--;
        }
        return true;

    }

}




import java.io.*;


public class Main {

    static int n = 25, row, col,cnt;
    static int[] dx = {-1, 0, 1, 0}, dy = {0, 1, 0, -1};
    static char[][] g = new char[n][n];

    public static void main(String[] args) throws Exception {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        while (true) { // 多组测试用例
            cnt = 0; // 每个用例都初始化一下 0
            String[] ss = reader.readLine().split(" ");
            row = Integer.parseInt(ss[1]);
            col = Integer.parseInt(ss[0]);
            // 读到0 0 结束
            if (row == 0 || col == 0) break;
            int x = 0, y = 0;

            for (int i = 0; i < row; i++) {
                String s = reader.readLine();
                for (int j = 0; j < col; j++) {
                    g[i][j] = s.charAt(j);
                    if (g[i][j] == '@') { // 记录一下初始化的x y的位置
                        x = i;
                        y = j;
                    }
                }
            }
            dfs(x, y); // 开始dfs
            System.out.println(cnt);
        }
    }

    static void dfs(int x, int y) {
        g[x][y] = '#'; // 标记一下 走过了
        cnt++;
        for (int i = 0; i < 4; i++) {
            int a = x + dx[i];
            int b = y + dy[i];
            // 不越界 且 为黑 才继续走
            if (a >= 0 && a < row && b >= 0 && b < col && g[a][b] == '.') {
                dfs(a, b);
            }
        }
    }
}




import java.util.*;

class Main{

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] f = new int[n][m];

        int[] dx = {0, 1, 0, - 1}, dy = {1, 0, -1, 0};
        int d = 0, x = 0, y = 0, k = 1;

        while(k <= m * n){

            int a = x + dx[d];
            int b = y + dy[d];
            if(a >= n || b >= m || a < 0 || b < 0 || f[a][b] != 0) d = (d + 1) % 4;
            f[x][y] = k;
            x += dx[d];
            y += dy[d];
            k ++;
        }

        for(int[] nums : f){
            for(int num : nums){
                System.out.print(num + " ");
            }
            System.out.println();
        }

    }
}