結果

問題 No.2624 Prediction by Average
ユーザー tnakao0123tnakao0123
提出日時 2024-02-17 00:42:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 429 ms
コンパイル使用メモリ 42,048 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-17 00:42:17
合計ジャッジ時間 1,143 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 3 ms
6,676 KB
testcase_02 AC 4 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 4 ms
6,676 KB
testcase_05 AC 4 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2624.cc:  No.2624 Prediction by Average - yukicoder
 */

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

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

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

  while (tn--) {
    ll n;
    int x, y;
    scanf("%lld%d.%d", &n, &x, &y);
    ll s = x * 1000 + y;
    //printf(" n=%lld, s=%lld\n", n, s);
    
    int m = min(999LL, n);
    ll cnt = n - m;
    for (int k = 1; k <= m; k++) {
      ll x0 = (s * k + 999) / 1000;
      ll x1 = ((s + 1) * k - 1) / 1000;
      //printf("  k=%d, x0=%lld, x1=%lld\n", k, x0, x1);
      if (x0 <= x1) cnt++;
    }

    printf("%lld\n", cnt);
  }

  return 0;
}
0