結果

問題 No.356 円周上を回る3つの動点の一致
コンテスト
ユーザー satanic
提出日時 2016-04-01 22:59:33
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 857 bytes
コンパイル時間 645 ms
コンパイル使用メモリ 65,368 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-02 09:18:18
合計ジャッジ時間 2,193 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 WA * 45 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>

int GetLCM(int A, int B){
    int a = A, b = B;
	int r=-1;
	if(a<b) std::swap(a, b);
	while(r!=0){
		r=a%b;
		a=b;
		b=r;
	}
	return A/a*B;
}

int PrimeFactNum(int n){
    int divCount = 0;
	for(int i=2; i<=n; ++i){
		if(n%i == 0){
			do{
				++divCount;
				n/=i;
			}while(n%i == 0);
		}
	}
	return divCount;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    std::vector<int> input(3);
    long long int lcm;
    int den=0;
    for(int i=0; i<3; ++i){
        std::cin >> input[i];
        den += PrimeFactNum(input[i]);
    }
    den /= 3;
    lcm = GetLCM(GetLCM(input[0], input[1]), input[2]);
    if(lcm%den==0){
        lcm /= den;
        den = 1;
    }
    
    std::cout << lcm << "/" << den << "\n";

    return 0;
}
0