結果

問題 No.25 有限小数
ユーザー ynq1242ynq1242
提出日時 2014-10-30 17:05:18
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,374 bytes
コンパイル時間 570 ms
コンパイル使用メモリ 77,784 KB
実行使用メモリ 7,836 KB
最終ジャッジ日時 2023-08-28 23:23:30
合計ジャッジ時間 7,225 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
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<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
#include<ctime>
#include<set>
using namespace std;


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define F first
#define S second
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

li gcd(li a, li b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(b, a%b);
}

int main(){
	li a,b;
	cin>>a>>b;
	b/=gcd(a,b);
	a/=gcd(a,b);
	li ni=0,go=0;
	li bb=b;
	while(b%2==0){b/=2; ni++;}
	while(b%5==0){b/=5; go++;}
	if(b>1){
		puts("-1");
		return 0;
	}
	li t=1;
	rep(i,max(ni,go))t*=10;
	t/=bb;
	a=(a%10)*t;
	while(a%10==0)a/=10;
	cout<<a%10<<endl;


	return 0;
}
0