zoukankan      html  css  js  c++  java
  • CodeForce727C. Guess the Array---交互题

    题目链接:http://codeforces.com/contest/727/problem/C

    题意:交互题; 
    printf(“? i j ”); 
    fflush(stdout); 
    然后scanf(“%d”,&d); 
    就能把系统给你的东西输入到d这个变量里了。 
    让你猜一个序列a[1..n]。 
    每次你可以询问任意两个数字的和。 
    最多使用n次询问,求出所有的序列; 

    太高大上第一次见;其实就是每次你问任意两个数的和,然后系统告诉你,然后存到一个数里面,然后只能问n次,就原数组是多少;

    #include<iostream>
    #include<algorithm>
    #include<math.h>
    #include<string.h>
    #include<stdio.h>
    #include<map>
    #include<vector>
    #include<queue>
    using namespace std;
    #define met(a, b) memset(a, b, sizeof(a))
    #define mod 1000000007
    typedef long long LL;
    //////////////////////////////////////////////////////////////
    const int INF = 0x3f3f3f3f;
    const int N = 5521;
    const double eps = 1e-8;
    
    int n, a[N];
    
    int main()
    {
        scanf("%d", &n);
    
        for(int i=1; i<n; i++)
        {
            printf("? 1 %d
    ", i+1);
            fflush(stdout);
            scanf("%d", &a[i]);
        }
        printf("? 2 3
    ");
        fflush(stdout);
        scanf("%d", &a[n]);
        int x = (a[1]+a[2]-a[n])/2;
        printf("! %d", x);
        fflush(stdout);
    
        for(int i=1; i<n; i++)
        {
            printf(" %d", a[i]-x);
            fflush(stdout);
        }
        printf("
    ");
        fflush(stdout);
        return 0;
    }
    View Code
  • 相关阅读:
    EBS R12.2 运行请求出错
    仿ORACLE的TRUNC函数
    EBS职责清单(Responsibility)
    Oracle 11G Client 客户端安装步骤
    UltraIso-写入硬盘映像
    EBS-WIP完工入库
    LeetCode 2 两数相加
    LeetCode 1.两数之和
    装饰器示例
    爬虫day1
  • 原文地址:https://www.cnblogs.com/zhengguiping--9876/p/5990109.html
Copyright © 2011-2022 走看看