結果
| 問題 |
No.25 有限小数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-15 06:34:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 403 bytes |
| コンパイル時間 | 835 ms |
| コンパイル使用メモリ | 64,128 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 02:38:46 |
| 合計ジャッジ時間 | 2,080 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 29 WA * 2 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
5 | main()
| ^~~~
ソースコード
#include<iostream>
using namespace std;
long N,M;
long gcd(long a,long b){return b?gcd(b,a%b):a;}
main()
{
cin>>N>>M;
long d=gcd(N,M);
N/=d;
M/=d;
int c2=0,c5=0;
while(M%2==0)c2++,M/=2;
while(M%5==0)c5++,M/=5;
if(M!=1)
{
cout<<-1<<endl;
return 0;
}
if(N%10==0)
{
cout<<0<<endl;
return 0;
}
N%=10;
for(int i=c2;i<c5;i++)N=N*2%10;
for(int i=c5;i<c2;i++)N=N*5%10;
cout<<N<<endl;
}