結果

問題 No.25 有限小数
ユーザー ninoinui
提出日時 2020-07-23 10:30:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 501 bytes
コンパイル時間 2,664 ms
コンパイル使用メモリ 202,084 KB
最終ジャッジ日時 2025-01-12 04:10:25
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 WA * 2 RE * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <boost/lexical_cast.hpp>
using namespace std;
using namespace boost;

int main() {
  long N, M;
  cin >> N >> M;
  if (M % 2 && M % 5) return cout << -1 << "\n", 0;
  int n = to_string(N).size();
  int m = to_string(M).size();
  while (n < m) N *= 10, n++;
  while (m < n) M *= 10, m++;
  if (N / M == (double) N / M) return cout << N / M << "\n", 0;
  string ans = lexical_cast<string> ((double) N / M + 1e-15);
  cout << ans.at((int) ans.find("000") - 1) << "\n";
}
0