Educational Codeforces Round 65 (Rated for Div. 2) B. Lost Numbers

链接:https://codeforces.com/contest/1167/problem/B

题意:

This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or flush(output) in Pascal to flush the output. If you use some other programming language, consult its documentation. You may also refer to the guide on interactive problems: https://codeforces.com/blog/entry/45307.

The jury guessed some array aa consisting of 66 integers. There are 66 special numbers — 44, 88, 1515, 1616, 2323, 4242 — and each of these numbers occurs in aa exactly once (so, aa is some permutation of these numbers).

You don't know anything about their order, but you are allowed to ask up to 44 queries. In each query, you may choose two indices ii and jj (1i,j61≤i,j≤6, ii and jj are not necessarily distinct), and you will get the value of aiajai⋅aj in return.

Can you guess the array aa?

The array aa is fixed beforehand in each test, the interaction program doesn't try to adapt to your queries.

交互题,根据你给的计算顺序来求他的原顺序。

思路:

得到1*2 2*3 3*4 4*5位置的值,然后直接枚举。

代码:

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

int A[10] = {0, 4, 8, 15, 16, 23, 42};
const int sum = 108;
map<int, int> ma;
int B[10];

bool check()
{
    ma[4] = 1;
    ma[8] = 2;
    ma[15] = 3;
    ma[16] = 4;
    ma[23] = 5;
    ma[42] = 6;
    int tmp = 0;
    for (int i = 1;i <= 5;i++)
    {
        if (ma[B[i]] == 0)
            return false;
        tmp += B[i];
    }
    B[6] = sum - tmp;
    return true;
}

int main()
{

    int ab, bc, cd, de;
    cout << '?' << ' ' << 1 << ' ' << 2 << endl;
    fflush(stdout);
    scanf("%d", &ab);
    cout << '?' << ' ' << 2 << ' ' << 3 << endl;
    fflush(stdout);
    scanf("%d", &bc);
    cout << '?' << ' ' << 3 << ' ' << 4 << endl;
    fflush(stdout);
    scanf("%d", &cd);
    cout << '?' << ' ' << 4 << ' ' << 5 << endl;
    fflush(stdout);
    scanf("%d", &de);
    for (int i = 1;i <= 6;i++)
    {
        if (ab % A[i] != 0)
            continue;
        B[1] = A[i];
        B[2] = ab / B[1];
        if (bc % B[2] != 0)
            continue;
        B[3] = bc / B[2];
        if (cd % B[3] != 0)
            continue;
        B[4] = cd / B[3];
        if (de % B[4] != 0)
            continue;
        B[5] = de / B[4];
        if (check())
            break;
    }
    fflush(stdout);
    cout << '!' << ' ';
    for (int i = 1;i <= 6;i++)
        cout << B[i] << ' ' ;
    cout << endl;

    return 0;
}

  

转载于:https://www.cnblogs.com/YDDDD/p/10900229.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值