結果

問題 No.2624 Prediction by Average
ユーザー Nzt3Nzt3
提出日時 2024-02-09 22:50:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 501 bytes
コンパイル時間 2,086 ms
コンパイル使用メモリ 201,644 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-09 22:50:50
合計ジャッジ時間 2,656 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void solve();
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int test_case;
  cin>>test_case;
  while (test_case--){
    solve();
  }
}
void solve(){
  ll N;
  string S;
  cin>>N>>S;
  ll C=0;
  for(int i=(int)S.size()-3;i<(int)S.size();i++){
    C=C*10+(S[i]-'0');
  }
  C=(1000-C)%1000;
  ll ans=max(0ll,N-1000);
  for(int i=1;i<=min(N,1000ll);i++){
    if(C*i%1000<i){
      ans+=1;
    }
  }
  cout<<ans<<'\n';
}
0