結果

問題 No.1842 Decimal Point
ユーザー tnakao0123tnakao0123
提出日時 2022-02-19 18:38:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 661 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 41,176 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 20:50:39
合計ジャッジ時間 1,337 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 44 ms
4,376 KB
testcase_02 AC 108 ms
4,376 KB
testcase_03 AC 93 ms
4,380 KB
testcase_04 AC 74 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1842.cc:  No.1842 Decimal Point - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

int powmod(int a, int n, int mod) {  // a^n % MOD
  int pm = 1;
  while (n > 0) {
    if (n & 1) pm = (ll)pm * a % mod;
    a = (ll)a * a % mod;
    n >>= 1;
  }
  return pm;
}

/* main */

int main() {
  int tn;
  scanf("%d", &tn);

  while (tn--) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);

    int d = (ll)(a % b) * powmod(10, c - 1, b) % b;
    int e = (ll)d * 10 / b;
    printf("%d\n", e);
  }
  return 0;
}
0