結果
| 問題 |
No.25 有限小数
|
| コンテスト | |
| ユーザー |
Kutimoti_T
|
| 提出日時 | 2017-12-18 21:22:44 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 496 bytes |
| コンパイル時間 | 393 ms |
| コンパイル使用メモリ | 54,564 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-16 00:35:30 |
| 合計ジャッジ時間 | 1,224 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 10 |
ソースコード
#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++;
}
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;
}
Kutimoti_T