結果
問題 | No.25 有限小数 |
ユーザー |
|
提出日時 | 2019-10-15 06:34:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 403 bytes |
コンパイル時間 | 609 ms |
コンパイル使用メモリ | 64,000 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 02:39:41 |
合計ジャッジ時間 | 1,819 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 1 |
コンパイルメッセージ
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<<1<<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; }