2019 ICPC徐州区域赛-F题

该博客介绍了2019年ICPC徐州区域赛中的一道题目,探讨了如何找到每个0到200的整数作为三立方和的解决方案。博主通过暴力打表的方法找到了满足条件的数字组合,对于找不到解决方案的情况输出"impossible"。
摘要由CSDN通过智能技术生成

2019 ICPC徐州区域赛-F题

For decades, scientists have wondered whether each of the numbers from 0 to 100 could be represented as the sum of three cubes, where a cube is the same number multiplied together three times.

42 was the last number without a proven solution — until now.

The solution is (-80538738812075974)^3 + 80435758145817515^3 + 12602123297335631^3 = 42(−80538738812075974)
3
+80435758145817515
3
+12602123297335631
3
=42

Now, Yen-Jen is suspicious of the existence of other solutions. But, the solutions are not so trivial to find out. Yen-Jen wants to find out easysolutions first. That is, for the equation a^3 + b^3 + c^3 = xa
3
+b
3
+c
3
=x,Yen-Jen wants to find out at least one solution for each integer xx in [0, 200][0,200],where |a|, |b|, |c| \le 5000∣a∣,∣b∣,∣c∣≤5000.

Since Yen-Jen is still busy preparing the test data of some(this?) problem, pleasehelp him find out at least one solution for each xx or tell him that thesolution doesn’t exist when |a|, |b|, |c| \le 5000∣a∣,∣b∣,∣c∣≤5000.

Input
The first line contains an integer TT indicating the number of xx to bechecked.Following TT lines each contains one integer xx.

1 \le T \le 101≤T≤10
0 \le x \le 2000≤x≤200
Output
For each test case, output one line containing three space-separated integers a, b, ca,b,c such that a^3 + b^3 + c^3 = xa
3
+b
3
+c
3
=x and |a|, |b|, |c| \le 5000∣a∣,∣b∣,∣c∣≤5000. If thesolution doesn’t exist, output impossible.

题意:满足题面条件的数字。

题解:以后一定好好先看数据范围再想做法。这道题我是直接暴力打表然后存进去。(因为一直推不出来公式)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int ans[210][3]={
-5000,0,5000,
-5000,1,5000,
-4373,-486,4375,
-5,4,4,
111111111,0,0,
111111111,0,0,
-637,-205,644,
-169,44,168,
-5000,2,5000,
-216,-52,217,
-650,-353,683,
-695,-641,843,
-11,7,10,
111111111,0,0,
111111111,0,0,
-265,-262,332,
-4114 ,-588 ,4118,
-3331 ,2195 ,2977,
-1373, -1276 ,1671,
-95 ,47 ,91,
-2816 ,-741, 2833,
-401 ,-287 ,445,
111111111,0,0,
111111111,0,0,
-10 ,8, 8,
-2683, 1839 ,2357,
-2107 ,237 ,2106,
-5000 ,3 ,5000,
-2268 ,-249, 2269,
-233 ,-69, 235,
111111111,0,0,
111111111,0,0,
111111111,0,0,
111111111,0,0,
-1555, -244, 1557,
-1120, -509 ,1154,
-3223, 2358 ,2731,
-444 ,-84 ,445,
-27 ,16, 25,
111111111,0,0,
111111111,0,0,
111111111,0,0,
111111111,0,0,
-823, -307 ,837,
-7 ,-5, 8,
-2369 ,1709, 2025,
-758, -473 ,815,
-141 ,49 ,139,
-3950 ,-1247, 3991,
111111111,0,0,
111111111,0,0,
-796, 602, 659,
111111111,0,0,
-2370, 1518, 2141,
-3885, -648, 3891,
-3329, 1837, 3131,
-672, 505, 559,
-998, 361, 982,
111111111,0,0,
111111111,0,0,
-1201, -163, 1202,
-966, 668, 845,
-2744, -1561, 2903,
-161, 102, 146,
-5000, 4, 5000,
-929, 403, 903,
1, 1, 4,
111111111,0,0,
111111111,0,0,
-403, 134, 398,
-2359, 824, 2325,
-533, 401, 443,
-432, -104, 434,
-335, -146, 344,
111111111,0,0,
111111111,0,0,
111111111,0,0,
111111111,0,0,
-2080, -829, 2123,
-706, -196, 711,
-1300, -706, 1366,
-2368, -1719, 2638,
-1317, 847, 1188,
-3707, 1315, 3651,
111111111,0,0,
111111111,0,0,
111111111,0,0,
-4126, -1972, 4271,
-1390, -1282, 1686,
-2514, 1953, 2036,
-1803, 365, 1798,
-3389, -2912, 3992,
-4052, 861, 4039,
-248, -98, 253,
111111111,0,0,
111111111,0,0,
-22, 14, 20,
-3168, -991, 3200,
-2101, -1638, 2391,
-893, -622, 984,
-1797, -903, 1870,
-2327, 319, 2325,
-239, 118, 229,
111111111,0,0,
111111111,0,0,
-7, -4, 8,
-2689, -1165, 2760,
-1309, 947, 1117,
-1165, -948, 1345,
-2948, 853, 2924,
111111111,0,0,
-4793, -2312, 4966,
111111111,0,0,
111111111,0,0,
111111111,0,0,
-12 ,8, 11,
-1906, -757, 1945,
-896, -555, 962,
-4328, 383, 4327,
-3677, -1673, 3789,
-2804, 1219, 2725,
111111111,0,0,
111111111,0,0,
-37, -16, 38,
-1, 0, 5,
-5000, 5, 5000,
-2212 ,-419, 2217,
-4034, -3881, 4988,
-3989 ,-726, 3997,
-1580, -1238, 1801,
111111111,0,0,
111111111,0,0,
-1, 2, 5,
-399, 167, 389,
-3013 ,-1766, 3203,
-1351 ,-629, 1395,
-1116, 816, 946,
-758, -428, 801,
-86, -77, 103,
111111111,0,0,
111111111,0,0,
-139, 104, 116,
-7 ,-3, 8,
111111111,0,0,
-2746, -2552, 3342,
-8 ,-7, 10,
-327 ,-263, 376,
-2366, 1528, 2131,
111111111,0,0,
111111111,0,0,
-367, 260, 317,
-463, 215, 447,
-805 ,486, 741,
-3736 ,-695, 3744,
-2135, -516, 2145,
-3693 ,-1049, 3721,
111111111,0,0,
111111111,0,0,
111111111,0,0,
-1534, 383, 1526,
-3874, -1654, 3972,
-4767, -2476, 4980,
-4125, -1417, 4180,
-3423, -2943, 4033,
-66, -59, 79,
111111111,0,0,
111111111,0,0,
111111111,0,0,
-802, -574, 890,
-1354, -1012, 1521,
-3834, -2149, 4047,
-1328, 891, 1178,
111111111,0,0,
111111111,0,0,
-335, -170, 349,
111111111,0,0,
111111111,0,0,
-1168 ,-160, 1169,
-13 ,-10, 15,
-2839 ,1503, 2691,
111111111,0,0,
-4874 ,974 ,4861,
-90 ,-29, 91,
-4889 ,976, 4876,
111111111,0,0,
111111111,0,0,
-4, 5, 5,
-1885, -1092, 2000,
-1639 ,318, 1635,
-1702 ,-1403, 1974,
-4812 ,-593, 4815,
-377 ,-215, 399,
-20, 16, 16,
111111111,0,0,
111111111,0,0,
111111111,0,0,
-1057 ,-579 ,1112,
-2867 ,-1606, 3026,
-3752 ,-1347, 3809,
-2208 ,508, 2199,
-2318, -638 ,2334};
ll ok(ll need) {
    ll l = -5000, r = 5000, res = -12345678;
    while (r - l >= 0) {
        ll mid = (l + r) >> 1;
        ll tmp = mid * mid * mid;
        if (tmp == need) {
            return mid;
        }
        if (tmp > need) {
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    return res;
}

bool gao(int x) {
    int limit = 5000;
    for (ll a = -limit; a <= limit; ++a) {
        for (ll b = -limit; b <= limit; ++b) {
            ll need = 1ll * x - a * a * a - b * b * b;
            ll c = ok(need);
            if (abs(c) <= 5000) {
                cout << a << " " << b << " " << c << endl;
                return true;
            }
        }
    }
    return false;
}
int main() {
//    int cnt = 0;
//    int Y = -12345678;
//    for (int i = 0; i <= 200; ++i) {
//        if (!gao(i)) {
//            puts("111111111");
//        }
//    }
    int t; cin>>t;
    while(t--){
        int c;
        cin>>c;
        if(ans[c][0]==111111111)puts("impossible");
        else cout<<ans[c][0]<<' '<<ans[c][1]<<' '<<ans[c][2]<<endl;
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值