結果

問題 No.25 有限小数
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-15 06:45:39
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 557 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 24,992 KB
実行使用メモリ 6,088 KB
最終ジャッジ日時 2023-09-22 16:06:45
合計ジャッジ時間 7,589 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 0 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 573 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

long long int gcd( long long int a, long long int b){
	if(b == 0){
		return a;
	}
	
	if(a > b){
		return gcd(b,a%b);
	}else{
		return gcd(a,b%a);
	}
}

int main(void){
	long long int n,m,g, tmp;
	
	
	scanf("%lld", &n);
	scanf("%lld", &m);
	g = gcd(n,m);
	
	n /= g;
	m /= g;
	tmp = m;
	
	while( tmp%2 == 0 ){ tmp/=2;}
	while( tmp%5 == 0 ){ tmp/=5;}
	if(tmp == 1){
		while(n%m != 0){
			while( n>m ){n = n-m;}
			n *= 10;
		}
		n /= m;
		while(n%10==0){n/=10;}
		n = n%10;
		printf("%lld\n", n);
	}else{
		printf("-1\n");
	}
	
	return 0;
}
0