SW_Expert
[SW Expert Academy] 3376. 정사각형 분할 놀이
코드와이
2021. 2. 4. 17:48
문제링크
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
package D3;
import java.util.Scanner;
public class 정삼각형_분할_놀이 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
StringBuilder sb = new StringBuilder();
int T = sc.nextInt();
for( int tc = 1 ; tc <= T ; tc++) {
sb.append("#" + tc + " ");
long n = sc.nextLong();
long m = sc.nextLong();
long ans = 0l;
for( int i = 1 ; i <= n / m ; i++) {
ans += 2 * i - 1;
}
sb.append(ans);
System.out.println(sb);
sb.setLength(0);
}
}
}