为什么会掉精度
查看原帖
为什么会掉精度
574944
Micnation_AFO楼主2023/1/17 10:17

rt,过不去 hack,用的是 __int128

#include <iostream>
#include <cmath>

using namespace std;
#define int __int128

int T;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') { f = (ch == '-' ? -1 : f); ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}

void write(int x) {
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

void solve() {
    int n = read(), m = read();
    if (n >= 64) {
        puts("No");
        return;
    }
    if ((1 << (n - 1)) > m) {
        puts("No");
        return;
    }
    puts("Yes");
    int ans = 1;
    while (n--) write(ans), putchar(' '), ans <<= 1;
    puts("");
}

signed main() {
    T = read();
    while (T--) solve();
    return 0;
}

2023/1/17 10:17
加载中...