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 ...
随机推荐
- 15 个最佳的 jQuery 布局插件【转】
英文原文:15 Best jQuery Grid Plugins for Developers 现如今,网站开发设计的需求会要求自动适应所有移动设备,即响应式网站: 在开发网站时必须考虑对平板设备融合 ...
- IntelliJ IDEA 同时启动多个Tomcat实例端口是会冲突
- 每天一个linux命令(5):mkdir命令
版权声明更新:2017-05-09博主:LuckyAlan联系:liuwenvip163@163.com声明:吃水不忘挖井人,转载请注明出处! 1 文章介绍 本文介绍了Linux下命令mkdir. 2 ...
- ACM学习历程—HDU 4287 Intelligent IME(字典树 || map)
Description We all use cell phone today. And we must be familiar with the intelligent English input ...
- ACM学习历程—HDU 1276 士兵队列训练问题(队列)
Description 某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠 拢,再从头开始进行一至三报数,凡 ...
- 算法导论笔记——第二十章 van Emde Boas树
当关键字是有界范围内的整数时,能够规避Ω(lglgn)下界的限制,那么在类似的场景下,我们应弄清楚o(lgn)时间内是否可以完成优先队列的每个操作.在本章中,我们将看到:van Emde Boas树支 ...
- Jasper:推送 API
ylbtech-Jasper:推送 API Control Center 还维护一个“推送 API”系统,一旦发生特定事件,就会向应用程序发送编程通知.例如,您可能选择在设备接近流量上限时收到通知.或 ...
- 表单enctype属性
首先知道enctype这个属性管理的是表单的MIME编码.共有三个值可选:1.application/x-www-form-urlencoded2.multipart/form-data3.text/ ...
- windows下搭建nginx服务器及实现nginx支持https配置流程
最近刚接触到了tomcat结合nginx做网站的负载均衡.之前对tomcat搭配nginx实现负载均衡也写过,在上一篇的博客中,最近遇到的问题是要在http的基础上支持https.也就是支持加密的请求 ...
- 二维数组是二级指针pointer to pointer!
二维数组居然是个类似于二级指针(pointer to pointer)的东西,十分震惊! #include <stdio.h> int main() { ][]={{,,,},{,,,}, ...