結果

問題 No.2624 Prediction by Average
ユーザー planesplanes
提出日時 2024-02-09 22:32:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 970 bytes
コンパイル時間 1,469 ms
コンパイル使用メモリ 168,808 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-09 22:32:48
合計ジャッジ時間 1,983 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

ll INF=2e18;

void solve() {
ll N;cin>>N;
string S;cin>>S;
string t="";
for(auto x:S) {
  if(x=='.') continue;
  t+=x;
}

ll a=stoll(t);
ll ans=0;
for(ll i=1;i<=min(2000LL,N);i++) {
  if(a*i%1000==0) ans++;
  else if(a*i/1000<(a+1)*i/1000&&(a+1)*i%1000!=0) {
    ans++;
   
  }
}

if(N>2000) ans+=N-2000;

cout<<ans<<endl;



}
/*

小数点4以下がxであった時,(S+x)*iが整数となるような,(x,i)の組み合わせが
1つでも存在すれば,i人は認められる
総和をKと決めて,S*i<=K<(S+0.001)*iであるiはすべてOK
S*i*1000と(S*1000+1)*iをみてK000があればよい.
確実にいけてるのはi>=1000のとき,
*/

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll t;cin>>t;
  for(ll i=0;i<t;i++) {
    solve();
  }

}


  
0