結果

問題 No.2624 Prediction by Average
ユーザー 👑 chro_96chro_96
提出日時 2024-02-09 22:16:37
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 850 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 30,592 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-02-09 22:16:37
合計ジャッジ時間 668 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int main () {
  int t = 0;
  long long n = 0LL;
  char s[8] = "";
  
  int res = 0;
  
  res = scanf("%d", &t);
  while (t > 0) {
    long long ans = 0LL;
    long long sd = 0LL;
    int idx = 0;
    int p = -1;
    res = scanf("%lld", &n);
    res = scanf("%s", s);
    while (s[idx] != '\0') {
      if (s[idx] == '.') {
        p = idx;
      } else {
        sd *= 10LL;
        sd += (long long)(s[idx]-'0');
      }
      idx++;
    }
    if (p < 0) {
      sd *= 1000LL;
    } else if (idx-p == 2) {
      sd *= 100LL;
    } else if (idx-p == 3) {
      sd *= 10LL;
    }
    for (long long i = 1LL; i <= 1000LL; i += 1LL) {
      if (i <= n && (1000LL-(i*sd)%1000LL)%1000LL < i) {
        ans += 1LL;
      }
    }
    if (n > 1000LL) {
      ans += n-1000LL;
    }
    printf("%lld\n", ans);
    t--;
  }
  
  return 0;
}
0