QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#747751 | #9622. 有限小数 | guodong# | WA | 0ms | 3928kb | C++17 | 1.2kb | 2024-11-14 18:07:03 | 2024-11-14 18:07:04 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(x, l, r) for(int x = l; x <= r; x++)
using namespace std;
typedef long long ll;
int pw2[105], pw5[105];
const int INF = 0x3f3f3f3f;
const ll XX = 1ll << 55;
int main(){
int t;
scanf("%d", &t);
while(t--){
int a, b, res = 1;
scanf("%d%d", &a, &b);
while(b % 2 == 0){
res *= res * 2;
b /= 2;
}
while(b % 5 == 0){
res *= res * 5;
b /= 5;
}
// printf(" %d %d\n", a, b);
int ans = INF;
ll s = 1, ans2;
rep(i, 0, 60){
ll ss = s;
rep(j, 0, 60){
// printf("%d %d : %lld %lld %lld \n", i, j, s, ss, (b - (ss % b * a) % b) % b );
if((b - (ss % b * a) % b) % b < ans){
ans = (b - (ss % b * a) % b) % b;
ans2 = res * ss * b;
}
// ans = max((ll)ans, ss % b);
if(res * b * ss * 5 > XX) break;
ss = ss * 5;
}
if(res * b * s * 2 > XX) break;
s = s * 2;
}
printf("%d %lld\n", ans, ans2);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3928kb
input:
4 1 2 2 3 3 7 19 79
output:
0 2 1 3 1 4375 3 1506805419921875
result:
wrong answer Integer 1506805419921875 violates the range [1, 10^9]