結果
問題 | No.25 有限小数 |
ユーザー |
|
提出日時 | 2019-10-15 06:35:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 377 bytes |
コンパイル時間 | 507 ms |
コンパイル使用メモリ | 64,000 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 02:42:45 |
合計ジャッジ時間 | 1,525 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
コンパイルメッセージ
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; } while(N%10==0)N/=10; 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; }