結果
| 問題 |
No.2624 Prediction by Average
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-09 21:56:45 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,119 bytes |
| コンパイル時間 | 2,924 ms |
| コンパイル使用メモリ | 253,712 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-09-28 15:12:45 |
| 合計ジャッジ時間 | 3,061 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 WA * 4 |
ソースコード
// #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;
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;
}
/*
*/