QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#756550#9622. 有限小数proking#WA 0ms3500kbC++141.6kb2024-11-16 20:55:022024-11-16 20:55:03

Judging History

你现在查看的是最新测评结果

  • [2024-11-16 20:55:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3500kb
  • [2024-11-16 20:55:02]
  • 提交

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");
			continue;
		}
		
		ll s = 1, c = 1e9;
		F(x, 0, 30) {
			ll t = s;
			F(y, 0, 13) {
				if (t > 1e9) 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: 0
Wrong Answer
time: 0ms
memory: 3500kb

input:

4
1 2
2 3
3 7
19 79

output:

0
1 3
1 4375
3 316

result:

wrong answer The result is not terminating.(Testcase 2)