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;
    }
    

      

  • 相关阅读:
    Linux常用指令整理
    结构型模式-组合模式(树形结构的处理)
    结构型模式-适配器模式(不兼容结构的协调)
    创建型模式-原型模式(对象的克隆)
    创建型模式-单例模式(确保对象唯一性)
    创建型模式-抽象工厂
    Linux之linux下安装mysql
    关于elipse中maven搭建好后,一直building workspace的问题
    idea配置数据库下载驱动
    idea配置maven以及手动添加webapp目录
  • 原文地址:https://www.cnblogs.com/YDDDD/p/10900229.html
Copyright © 2011-2022 走看看