結果

問題 No.2624 Prediction by Average
ユーザー planesplanes
提出日時 2024-02-09 22:36:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 1,034 bytes
コンパイル時間 1,744 ms
コンパイル使用メモリ 167,716 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-09-28 15:48:18
合計ジャッジ時間 1,904 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5
権限があれば一括ダウンロードができます

ソースコード

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++;
    continue;
  }

  ll x=a*i/1000;
  ll y=(a+1)*i/1000;
  if(x+1<y) ans++;
  else if(x+1==y&&(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