結果

問題 No.2624 Prediction by Average
ユーザー norikamenorikame
提出日時 2024-02-09 23:14:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 906 bytes
コンパイル時間 4,199 ms
コンパイル使用メモリ 263,292 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-09 23:14:18
合計ジャッジ時間 4,703 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// 

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

const int INF = (int)(1e9);

int main() {
	int t0;
	cin >> t0;
	rep(i0, t0) {
		ll n;
		string s;
		cin >> n >> s;
		int pi = s.find('.'), si = stoi(s.substr(0, pi)) * 1000 + stoi(s.substr(pi+1));
		ll li = 0, ri = n+1;
		while (ri-li > 1) {
			ll ci = li + (ri-li) / 2, lval = si * ci, rval = (si+1) * ci;
			if (rval-lval < 1000) li = ci;
			else ri = ci;
		}
		ll res = (n+1) - ri;
		rep3(i, 1, ri) if (si*(ll)i/1000 < (si+1)*(ll)i/1000 || si*(ll)i%1000 == 0) ++res;
		cout << res << endl;
	}
	return 0;
}
0