P2241 统计正方形和长方形

import java.util.Scanner;

public class P2241 {
	static int T,n,m;
	static Long a,b;//a正方形个数,b长方形个数。
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			n = sc.nextInt();
			m = sc.nextInt();
			a = 0l;
			b = 0l;
			for(int i=1;i<=n;i++) {
				for(int j=1;j<=m;j++) {
					a += Math.min(i, j);
					b += i*j;
				}
			}
			System.out.println(a+" "+(b-a));
	}
}

猜你喜欢

转载自blog.csdn.net/qq_28635317/article/details/114064007