QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#756587 | #9622. 有限小数 | proking# | WA | 5ms | 3700kb | C++14 | 1.6kb | 2024-11-16 21:03:34 | 2024-11-16 21:03:35 |
Judging History
answer
#include <bits/stdc++.h>
#define F(i, a, b) for (int i = a; i <= b; i ++)
#define G(i, a, b) for (int i = a; i >= b; i --)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define mx(a, b) ((a) = max(a, b))
#define mn(a, b) ((a) = min(a, b))
#define get getchar()
#define putc putchar
#define outarr(a, L, R) { printf(#a"[%d..%d]", L, R); F(i, L, R) W(a[i]), putc(' ') ; putc('\n'); }
#define out1(x) { printf(#x" = "), W(x), putc('\n'); }
#define out2(x, y) { printf(#x" = "), W(x), printf(" "#y" = "), W(y), putc('\n'); }
#define out3(x, y, z) { printf(#x" = "), W(x), printf(" "#y" = "), W(y), printf(" "#z" = "), W(z), putc('\n'); }
using namespace std;
template <typename Int>
void R(Int &x) {
char c = get; x = 0; Int t = 1;
for (; !isdigit(c); c = get) t = (c == '-' ? -1 : t);
for (; isdigit(c); x = (x << 3) + (x << 1) + c - '0', c = get); x *= t;
}
template <typename Int>
void W(Int x) {
if (x < 0) { putc('-'); x = - x; }
if (x > 9) W(x / 10); putc(x % 10 + '0');
}
#define pb push_back
#define ll long long
const int N = 5e5 + 10;
ll T, a, b, c, d;
int main() {
// freopen("data.in","r",stdin);
for (R(T); T --; ) {
R(a), R(b); int b_ = b;
while (b % 2 == 0) b /= 2;
while (b % 5 == 0) b /= 5;
if (b == 1) {
puts("0 1");
continue;
}
ll s = 1, c = 1e9;
F(x, 0, 30) {
ll t = s;
F(y, 0, 13) {
if (t > 1e9 / b) break;
ll k = (a * t - 1) / b + 1;
if (k * b - a * t < c)
c = k * b - a * t, d = b * t;
t = t * 5;
}
s = s * 2;
}
W(c), putc(' '), W(d);
putc('\n');
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
input:
4 1 2 2 3 3 7 19 79
output:
0 1 1 3 1 4375 3 316
result:
ok 4 case(s)
Test #2:
score: -100
Wrong Answer
time: 5ms
memory: 3700kb
input:
10000 11 12 28 53 17 60 2 35 17 181 80 123 68 141 79 163 71 99 13 64 33 61 15 32 16 61 11 86 33 74 128 143 40 53 7 23 30 31 5 6 86 181 73 91 13 23 71 81 1 2 7 38 117 160 33 83 129 151 88 153 25 58 16 19 19 141 95 124 43 96 71 139 11 59 106 109 93 152 34 43 17 99 1 57 20 159 16 25 5 73 159 170 172 17...
output:
1 3 1 828125000 1 3 1 21875 1 231680000 23 960937500 1 36096000 5 326 1 63360 0 1 1 61000 0 1 1 4880 1 5375 1 9250 1 11714560 1 331250 1 898437500 1 31 1 3 1 289600000 1 455000 1 115000000 1 1265625 0 1 1 14843750 0 1 1 415 1 235937500 1 765000000 1 90625 1 2968750 1 4406250 3 6200 1 15 3 347500 1 9...
result:
wrong answer The result is not terminating.(Testcase 3)