CF753B题解
这应该算是一个很脍炙人口的小游戏了吧 (没玩过算我没说)
因为一共有 \(50\) 次询问机会,那最简单直接的方法就不难想到。
我们把 \(0 \sim9\) 全部询问一遍,如果回答两个整数不全为 \(0\),说明答案数字里有这个数码,然后我们把这个数记下来。这就用了\(10\)次。
然后我们把这四个数的所有排列全部询问一遍,如果得到 \(4,0\) 的回答就直接结束。最多需要 \(4!=24\) 次,所以一共最坏只需要 \(34\) 次完全没问题。
反正我小时候3次就猜出来了
小坑点:在第一遍询问0的时候要输出0000的字符串不能直接输出0!!!
#include<bits/stdc++.h>
using namespace std;
bool use[10];
int main()
{
int a[10];
memset(use, 1, sizeof(use));
int cnt = 0;
for(int i = 0; i <= 9; i++)//0~9全部询问
{
if(i != 0)
cout << i * 1000 + i * 100 + i * 10 + i << endl;
else
cout << "0000" << endl;//这里要输出字符串
int A, b;
cin >> A >> b;
if(A || b) //记录出现过的数字
a[++cnt] = i, use[i] = 0;
}
int c, d;
for(int i = 1; i <= cnt; i++)//暴力全排列
for(int j = 1; j <= cnt; j++)
for(int k = 1; k <= cnt; k++)
for(int l = 1; l <= cnt; l++)
{
if(i == j || i == k || i == l || j == k || j == l || k == l)
continue;
cout << a[i] << a[j] << a[k] << a[l] << endl;
int c, d;
cin >> c >> d;
if(c == 4)
return 0;
}
system("pause");
return 0;
}
CF753B题解的更多相关文章
- 2016 华南师大ACM校赛 SCNUCPC 非官方题解
我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...
- noip2016十连测题解
以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...
- BZOJ-2561-最小生成树 题解(最小割)
2561: 最小生成树(题解) Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1628 Solved: 786 传送门:http://www.lyd ...
- Codeforces Round #353 (Div. 2) ABCDE 题解 python
Problems # Name A Infinite Sequence standard input/output 1 s, 256 MB x3509 B Restoring P ...
- 哈尔滨理工大学ACM全国邀请赛(网络同步赛)题解
题目链接 提交连接:http://acm-software.hrbust.edu.cn/problemset.php?page=5 1470-1482 只做出来四道比较水的题目,还需要加强中等题的训练 ...
- 2016ACM青岛区域赛题解
A.Relic Discovery_hdu5982 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Jav ...
- poj1399 hoj1037 Direct Visibility 题解 (宽搜)
http://poj.org/problem?id=1399 http://acm.hit.edu.cn/hoj/problem/view?id=1037 题意: 在一个最多200*200的minec ...
- 网络流n题 题解
学会了网络流,就经常闲的没事儿刷网络流--于是乎来一发题解. 1. COGS2093 花园的守护之神 题意:给定一个带权无向图,问至少删除多少条边才能使得s-t最短路的长度变长. 用Dijkstra或 ...
- CF100965C题解..
求方程 \[ \begin{array}\\ \sum_{i=1}^n x_i & \equiv & a_1 \pmod{p} \\ \sum_{i=1}^n x_i^2 & ...
- JSOI2016R3 瞎BB题解
题意请看absi大爷的blog http://absi2011.is-programmer.com/posts/200920.html http://absi2011.is-programmer.co ...
随机推荐
- 【Java】将枚举类转换为Redis字典缓存
字典翻译框架实现看这篇: https://www.cnblogs.com/mindzone/p/16890632.html 枚举的特性 首先是枚举的一些特性: 1.枚举实例直接在枚举类中声明 2.重载 ...
- 【转载】 tf.slice()介绍
原文地址: https://blog.csdn.net/nini_coded/article/details/79852031 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议, ...
- CentOS下离线安装gcc环境,图文详细,方法全面
CentOS下离线安装gcc环境,图文详细,方法全面 下载 方式1:如果有网的虚拟机还没有安装,可以直接 yum install --downloadonly --downloaddir=/root/ ...
- 【LCA 树上两点的距离 判定点是否在某条边中】洛谷P3398 仓鼠找sugar
题目链接:P3398 仓鼠找 sugar - 洛谷 | (luogu.com.cn) 题目大意:判定一棵树上的两条边是否相交 Tag: [LCA] [树上两点间距离的计算] [如何判断与点在某条路径上 ...
- 15-canvas渐变色
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="U ...
- AtCoder Beginner Contest 310
freee Programming Contest 2023(AtCoder Beginner Contest 310) - AtCoder A - Order Something Else (atc ...
- ZPL Viewer工具网站
新上线的ZPL Viewer工具网站 大家好! 在工作中,我们经常需要设计和预览ZPL(Zebra Programming Language)文件.以前,我一直使用ZPL Design这类工具,但后来 ...
- 推荐7款美观且功能强大的WPF UI库
前言 经常看到有小伙伴在DotNetGuide技术社区交流群里提问:WPF有什么好用或者好看的UI组件库推荐的?,今天大姚给大家分享7款开源.美观.功能强大.简单易用的WPF UI组件库. WPF介绍 ...
- CANopen学习笔记(三)NMT
NMT NMT主要用来管理和控制各个节点的状态,具体协议可以分为以下四类: NMT protocol Node guard protocol Heartbeat protocol Bootup pro ...
- 2024 NepCTF
NepCTF NepMagic -- CheckIn 直接玩游戏就能出 注意有一关要把隐藏的方块全找到 NepCamera 先使用tshark读取数据 结果文件中发现大量jpeg头ffd8ffe0. ...