QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#740878 | #9622. 有限小数 | zjhhhzj | WA | 28ms | 11564kb | C++17 | 1016b | 2024-11-13 12:01:13 | 2024-11-13 12:01:13 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod (998244353)
#define PI 3.14159265358979323846
#define PII pair<ll,ll>
#define F first
#define S second
#define N 1000010
#define pb push_back
ll n,m;
vector<ll>vt;
void init(ll x) {
vt.pb(x);
if(x*2<=1e9)init(x*2);
if(x*5<=1e9)init(x*5);
}
void solve() {
cin>>n>>m;
auto it=*(lower_bound(vt.begin(),vt.end(),m));
//cout<<it<<'\n';
if(it==m){
cout<<"0 1\n";return;
}
ll c=m-n,c25;
for(auto x:vt) {
if(m*x>1e9)break;
ll ans=(x*n)%m;
if(ans)ans=m-ans;
if(ans<c) {
c=ans;
c25=x*m;
}
if(!c)break;
}
cout<<c<<' '<<c25<<'\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int _ = 1;
init(1);
sort(vt.begin(),vt.end());
cin >> _;
while (_--) {
solve();
}
return 0;
}
/*
4
1 2
2 3
3 7
19 79
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 28ms
memory: 11564kb
input:
4 1 2 2 3 3 7 19 79
output:
0 1 1 140698504728760 1 14 3 316
result:
wrong answer Integer 140698504728760 violates the range [1, 10^9]