結果

問題 No.280 歯車の問題(1)
コンテスト
ユーザー bal4u
提出日時 2019-05-05 09:30:14
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 670 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 262 ms
コンパイル使用メモリ 37,376 KB
最終ジャッジ日時 2026-02-22 03:16:28
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// yukicoder: No.280 歯車の問題(1)
// 2019.5.4 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
long long in()    // 非負整数の入力
{
	long long n = 0;
	int c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

long long gcd(long long a, long long b)
{
	long long r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

long long a, b;
void norm()
{
	long long g = gcd(a, b);
	if (g > 1) a /= g, b /= g;
}

int main()
{
	int N;
	long long p;
	
	N = (int)in()-2;
	a = in(), b = p = in(), norm();
	while (N--) a *= p, b *= in(), norm();
	printf("%lld/%lld\n", b, a);
	return 0;
}
0