Educational Codeforces Round 65 (Rated for Div. 2) B - Lost Numbers (枚举,全排列)

int a[10] = {4, 8, 15, 16, 23, 42}, d[5];
int main()
{
    for (int i = 1; i <= 4; i++)
    {
        printf("? %d %d\n", i, i + 1);
        fflush(stdout);
        cin >> d[i];
    }
    do
    {
        if (a[1] * a[0] == d[1] && a[2] * a[1] == d[2] && a[3] * a[2] == d[3] && a[4] * a[3] == d[4])
            break;
    } while (next_permutation(a, a + 6));
    printf("!");
    for (int i = 0; i < 6; i++)
        cout << " " << a[i];

    fflush(stdout);
    return 0;
}
发布了82 篇原创文章 · 获赞 1 · 访问量 1420

猜你喜欢

转载自blog.csdn.net/weixin_44116061/article/details/104108859