• Home
  • About
    • Ryureka Moment photo

      Ryureka

      Sin Prisa, Sin Pausa

    • About Me
    • Facebook
    • Github
    • Youtube
  • Projects
  • Posts
    • Posts
    • ProblemSolvings
    • Tags
    • Blog
    • Examples
  • ProblemSolving
    • ProblemSolving
    • BOJ
    • Programmers
    • SWEA
    • LeetCode
  • FrontEnd
    • FrontEnd
    • HTML
  • BackEnd
    • BackEnd
    • Server
      • Server
      • Spring
      • NodeJS
    • DataBase
      • DataBase
      • MySQL
      • MongoDB
  • Programming
    • Programming
    • Java
    • JS
    • Python
    • CleanCode
  • ComputerScience
    • DataStructure
    • Algorithm

[BOJ] 1010. 다리 놓기

15 Apr 2026

Reading time ~1 minute

  • 풀이

풀이

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int t = 0; t < T; t++) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			
			int MAX = Math.max(N, M);
			int MIN = Math.min(N, M);			
				
			double answer = factorial(MAX)/(factorial(MIN)*factorial(MAX-MIN));
			
			System.out.println(Math.round(answer));
		}
	}
	
	public static double factorial(int N) {
        if(N == 0) return 1.0;
		if(Math.abs(N - 1) <= 1e-12) return 1.0;
		else return N*factorial(N-1);
	}
}


조합수학 Share