結果

問題 No.25 有限小数
ユーザー ninoinuininoinui
提出日時 2020-07-23 10:30:48
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 501 bytes
コンパイル時間 6,235 ms
コンパイル使用メモリ 248,408 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-05 22:05:11
合計ジャッジ時間 10,034 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 2 ms
4,376 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 WA -
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

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