zoukankan      html  css  js  c++  java
  • 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;
    }
    

      

  • 相关阅读:
    xmap使用实例
    事务使用
    JQuery常用一些语法
    ORA01461: can bind a LONG value only for insert into a LONG column,不是中文长度问题,是ojdbc驱动
    如何配置,页面自动跳转?
    FFmpeg(四) 像素转换相关函数理解
    模板
    初级算法题记录(一)
    C# String.Format 指定字符串宽度和对齐方式
    ImageMagick 批量图片格式转换
  • 原文地址:https://www.cnblogs.com/YDDDD/p/10900229.html
Copyright © 2011-2022 走看看