結果

問題 No.25 有限小数
ユーザー Kutimoti_T
提出日時 2017-12-18 21:22:30
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 533 bytes
コンパイル時間 395 ms
コンパイル使用メモリ 54,452 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-16 00:35:29
合計ジャッジ時間 1,247 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

typedef long long ll;

ll N;
ll M;

int twoans[] = {2,4,8,6};


int main()
{
	cin >> N >> M;
	
	int two = 0;
	int five = 0;
	while(M % 2 == 0)
	{
		M /= 2;
		two++;
	}
	while(M % 5 == 0)
	{
		M /= 5;
		five++;
	}
	cout << two << ":" << five << endl;
	if(N % M == 0 || M == 1)
	{
		if(two < five)
		{
			cout << ((N%10) * twoans[(five - two - 1) % 4]) % 10 << endl;
		}
		else
		{
			cout << ((N%10) * 5 * (two - five)) % 10 << endl;
		}
	}
	else
	{
		cout << -1 << endl;
	}
	return 0;
			
}
0