結果

問題 No.2624 Prediction by Average
ユーザー AerenAeren
提出日時 2024-02-09 21:59:59
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,153 bytes
コンパイル時間 3,058 ms
コンパイル使用メモリ 252,936 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-09 22:00:03
合計ジャッジ時間 3,574 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// #pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
#if __cplusplus >= 202002L
using namespace numbers;
#endif



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	auto __solve_tc = [&](auto __tc_num)->int{
		long long th;
		string s;
		cin >> th >> s;
		{
			auto it = ranges::find(s, '.');
			if(it == s.end()){
				s += '.';
				it = prev(s.end());
			}
			s += string(4 - (s.end() - it), '0');
			erase(s, '.');
		}
		int avg = stoi(s) % 1000;
		if(avg == 999){
			avg = 0;
		}
		long long res = 0;
		{ // 0
			int req = 1000 / gcd(avg, 1000);
			res += th / req;
		}
		if(gcd(avg, 1000) == 1){ // 999
			int inv = 1;
			{
				int base = avg;
				for(auto e = 399; e; e >>= 1){
					if(e & 1){
						inv = inv * base % 1000;
					}
					base = base * base % 1000;
				}
			}
			int rem = 999 * inv % 1000;
			if(th >= rem){
				res += 1 + (th - rem) / 1000;
			}
		}
		cout << res << "\n";
		return 0;
	};
	int __tc_cnt;
	cin >> __tc_cnt;
	for(auto __tc_num = 0; __tc_num < __tc_cnt; ++ __tc_num){
		__solve_tc(__tc_num);
	}
	return 0;
}

/*

*/
0