【数学】C056_LQ_战疫情(暴力枚举)

一、Problem

在这里插入图片描述

21

二、Solution

方法一:暴力

import java.util.*;
import java.math.*;
import java.io.*;
public class Main{
	static class Solution {
		void init() {
			Scanner sc = new Scanner(new BufferedInputStream(System.in));
			int res = 0;
			for (int x = 1; x <= 21000; x++)
			for (int y = 1; y <= 21000; y++) {
				if (2*x + 100*y == 50000 && x + y >= 20000 && x + y <= 21000)
					res++;
			}
			System.out.println(res);
		}
	}
    public static void main(String[] args) throws IOException {  
        Solution s = new Solution();
		s.init();
    }
}

复杂度分析

  • 时间复杂度: O ( . . . ) O(...)
  • 空间复杂度: O ( . . . ) O(...)
原创文章 787 获赞 314 访问量 5万+

猜你喜欢

转载自blog.csdn.net/qq_43539599/article/details/105825691
LQ
今日推荐