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 (1≤i,j≤61≤i,j≤6, ii and jj are not necessarily distinct), and you will get the value of ai⋅ajai⋅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;
}
Educational Codeforces Round 65 (Rated for Div. 2) B. Lost Numbers的更多相关文章
- Educational Codeforces Round 65 (Rated for Div. 2)B. Lost Numbers(交互)
This is an interactive problem. Remember to flush your output while communicating with the testing p ...
- Educational Codeforces Round 65 (Rated for Div. 2)题解
Educational Codeforces Round 65 (Rated for Div. 2)题解 题目链接 A. Telephone Number 水题,代码如下: Code #include ...
- Educational Codeforces Round 65 (Rated for Div. 2) D. Bicolored RBS
链接:https://codeforces.com/contest/1167/problem/D 题意: A string is called bracket sequence if it does ...
- Educational Codeforces Round 65 (Rated for Div. 2) C. News Distribution
链接:https://codeforces.com/contest/1167/problem/C 题意: In some social network, there are nn users comm ...
- Educational Codeforces Round 65 (Rated for Div. 2) A. Telephone Number
链接:https://codeforces.com/contest/1167/problem/A 题意: A telephone number is a sequence of exactly 11 ...
- [ Educational Codeforces Round 65 (Rated for Div. 2)][二分]
https://codeforc.es/contest/1167/problem/E E. Range Deleting time limit per test 2 seconds memory li ...
- Educational Codeforces Round 65 (Rated for Div. 2)
A:签到. #include<bits/stdc++.h> using namespace std; #define ll long long #define inf 1000000010 ...
- Educational Codeforces Round 65 (Rated for Div. 2) E. Range Deleting(思维+coding)
传送门 参考资料: [1]:https://blog.csdn.net/weixin_43262291/article/details/90271693 题意: 给你一个包含 n 个数的序列 a,并且 ...
- Educational Codeforces Round 65 (Rated for Div. 2)(ACD)B是交互题,不怎么会
A. Telephone Number A telephone number is a sequence of exactly 11 digits, where the first digit is ...
随机推荐
- freemaker开发
推荐书籍 百度云盘 密码: c3m9 1. 前言 本书为<FreeMarker 2.3.19 中文版手册>,包含了freemarker开发得方方面面,可以作为开发freemarker的字典 ...
- CI公用模型
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * SEO管理系统 -- 公用模型 ...
- Visual Studio 2012简体中文专业版密钥(激活码)
VS2012 正式版在Beta版的基础上进行了很多改进,尤其是加入了全新的用户界面. VS2012 的硬件需求与VS2010相同,不过由于 Visual Studio 2012 利用了新版 Windo ...
- 「NOIP2016」「P1850」 换教室(期望dp
题目描述 对于刚上大学的牛牛来说,他面临的第一个问题是如何根据实际情况申请合适的课程. 在可以选择的课程中,有 2n2n 节课程安排在 nn 个时间段上.在第 ii(1 \leq i \leq n1≤ ...
- 「LuoguP2365」 任务安排(dp
题目描述 N个任务排成一个序列在一台机器上等待完成(顺序不得改变),这N个任务被分成若干批,每批包含相邻的若干任务.从时刻0开始,这些任务被分批加工,第i个任务单独完成所需的时间是Ti. 在每批任务开 ...
- 【Lintcode】104.Merge k Sorted Lists
题目: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexit ...
- [转]addEventListener的第三个参数
如果要把HTML元素的事件与某个函数绑定起来,可以有下面三种方法,以最常见的“点击”事件为例. 方法一: 直接在对应的HTML元素标签上绑定函数 ? 1 <button id='submit' ...
- Poj_1011_Sticks(剪枝)
一.Description 乔治拿来一组等长的木棒,将它们随机地砍断,使得每一节木棍的长度都不超过50个长度单位.然后他又想把这些木棍恢复到为裁截前的状态,但忘记了初始时有多少木棒以及木棒的初始长度. ...
- POJ2349(求生成树中符合题意的边)
Arctic Network Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 14977 Accepted: 4777 D ...
- 整理出来的一个windows关机、锁定、重启、注销 API调用
using System.Runtime.InteropServices; namespace HookDemo { class WindowsExit { [StructLayout(LayoutK ...