코딩스터디

7466. 팩토리얼과 최대공약수

애플앤마블 2019. 6. 4. 00:14
반응형
SMALL

Factorial by Sumana Chamrunworakiat from the Noun Project

#include<iostream>
using namespace std;

int main(){
	int T;
    cin>>T;
    for(int t=1; t<=T; t++){
    	cout<<"#"<<t<<" ";
        int N, K;
        cin>>N>>K;
        int result=1;
        if(N>=K){
        	result=K;
        }
        else{
        	for(int i=N; i>0; i--){
            	if(K%i==0){
                	result*=i;
                    K/=i;
                }
            }
        }
        cout<<result<<endl;
    }
    return 0;
}

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWnghFyq9eMDFAQU&categoryId=AWnghFyq9eMDFAQU&categoryType=CODE

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

www.swexpertacademy.com

본 문제는 swexpertacademy의 7466 문제입니다.

반응형
LIST