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

      

  • 相关阅读:
    Asp.Net Mvc: 应用BindAttribute
    Mvc内建功能(DefaultModelBinder)自动绑定。
    生成随机字母字符串(数字字母混和)
    C#中实现输入汉字获取其拼音(汉字转拼音)的2种方法
    集合里查找数据
    C#自定义导出数据到Excel中的类封装
    MySQL性能优化的最佳20+条经验
    DevExpress.XtraGrid.view.gridview 属性说明
    c# 连接Mysql数据库
    ADO.NET 结构 集中数据库联接结构
  • 原文地址:https://www.cnblogs.com/YDDDD/p/10900229.html
Copyright © 2011-2022 走看看