E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
Master-Mind
UVA 340
Master-Mind
Hints
这个题目的意思十分的不好理解:它的大意是:这是一个猜数游戏,input第一行是一行有多少个,第二行是designer的密码,后面的除了都是零的之外都是breaker手作的猜测;output第一个是即数值相等,又位置相等;第二个是数值相等,但位置不相同;output有一个大的陷阱:SampleInput4135511234335655161351355000010122245666912345678
蜗牛骑上天
·
2023-01-06 19:13
笔记
c++
职场和发展
算法
主脑提示(
Master-Mind
Hints )
题目MasterMindisagamefortwoplayers.Oneofthem,Designer,selectsasecretcode.Theother,Breaker,triestobreakit.Acodeisnomorethanarowofcoloreddots.Atthebeginningofagame,theplayersagreeuponthelengthNthatacodemu
zjsru_Beginner
·
2022-08-04 09:09
C++
C
算法
c++
UVA340 猜数字游戏的提示
Master-Mind
Hints
你的任务是实现一个经典的“猜数字”游戏。给定答案序列和用户猜的序列,统计有多少数字位置正确(设为AA),有多少数字在两个序列中都出现过但位置不对(BB)。输入包含多组数据。每组输入第一行为序列长度nn,第二行是答案序列,接下来是若干行猜测序列。猜测序列全00时表示该组数据结束。n=0n=0时输入结束。对于每一组数据,输出的开头应有一行**“Gamex:”(没有双引号,x为当前组数据的编号,从1开始
zqhf123
·
2020-09-15 06:22
UVA题解
例题3-4 猜数字游戏的提示(
Master-Mind
Hints)
#include#include#definemaxn1010usingnamespacestd;intmain(){intn,i;inta[maxn],b[maxn];intca=0;while(scanf("%d",&n)!=EOF&&n){printf("Game%d:\n",++ca);for(i=0;i
somniloquy___
·
2020-08-16 22:14
算法竞赛
入门经典(第2版)
UVA 340
Master-Mind
Hints
DescriptionMasterMindisagamefortwoplayers.Oneofthem,Designer,selectsasecretcode.Theother,Breaker,triestobreakit.Acodeisnomorethanarowofcoloreddots.Atthebeginningofagame,theplayersagreeuponthelengthNth
wikioi_bai
·
2020-08-13 23:13
UVA
---简单数学题
UVA 340 -
Master-Mind
Hints
这道题英文描述太冗余。最后看了有个小哥一句话描述的题意才明白了http://blog.163.com/kakarrot@yeah/blog/static/12011592520106241155854/。其实就是统计两个序列相同列相同数字的个数和不同列相同数字的个数。要注意,两列中任意一个元素如果已经用过就不能再用了。由于只有9个数字,所以只需要统计每个数字出现的个数即可。先把相同列相同数字的统计
weixin_30703911
·
2020-08-13 20:57
UVa
Master-Mind
Hints(猜数字+计数)
原题地址https://vjudge.net/problem/UVA-340题意:猜数字游戏。给定答案序列和猜测序列,统计有多少数字正确(A),多少数字在两个序列中都出现过但位置不对应(B)。解题思路本题是《算法竞赛入门经典》的例题3-4,原题的英文题目很复杂,但是玩过猜数字的都知道是什么意思:)猜测不限次数,输入0000结束这轮猜测;判断A非常简单,直接统计guess[i]==real[i]的个
weixin_30681615
·
2020-08-13 20:52
UVa340
Master-Mind
Hints
Master-MindHintsMasterMindisagamefortwoplayers.Oneofthem,Designer,selectsasecretcode.Theother,Breaker,triestobreakit.Acodeisnomorethanarowofcoloreddots.Atthebeginningofagame,theplayersagreeupontheleng
江枭
·
2020-08-13 19:06
UVa
uva 340
Master-Mind
Hints(水题)
点击打开链接直接在输入时统计A的数目即可,对于B,先统计1~9分别在目标串与比较串中出现的次数aa,bb,而且取小就是该数字对B的贡献,加起来最终减去A即可。几个月前写时估计我是不理解求B的部分的,只是盲目的为了刷题而刷题,其实还是太急功近利。最近几个月心态很不好,一度停滞不前甚至都没碰电脑,现在想想其实曾经带给我们的伤痛的事过去那段时间以后那都不是事,他们只是在教会我们成长而已。从现在起,认认真
smwqd_yehua_cx
·
2020-08-13 18:49
水题
OJ
——
UVA
Master-Mind
Hints
#include#includeintmain(){intsect[1010];intgame[1010];intn;intnum[15];intnum1[15];intxt[15];intbxt[15];intcountGame=0;while(1){scanf("%d",&n);if(n==0)break;intcountZero=0;memset(sect,0,sizeof(sect));m
走钢索的人Secret
·
2020-08-13 17:23
Master-Mind
Hints - UVa 340
Master-MindHints-Uva340https://vjudge.net/problem/UVA-340思路:直接统计A,因为A比较容易统计,相比之下B不容易统计,故要在B上使用一些技巧。分别统计答案序列与猜测序列中各个数字出现的次数,分别记为c1,c2,选择c1,c2中较小的数,把它给B,直到1~9之间的数字都统计完毕,最后B=B-A,那么,问题来了,为什么这样减呢?原因是:题目中说B
「已注销」
·
2020-08-13 12:45
刘汝佳的算法竞赛入门经典
UVA 340 -
Master-Mind
Hints 简单题 题面难看
讲真,第一遍读下来不知道在讲个什么东西大致就是有一个二人的game,一个designer和一个player,player可以guess很多次,每guess一次designer会给一个hint,任务就是要你输出每一次的hint好吧,至于题目给了两个matches的independent的定义,以及一个集合independent的定义,这里我没怎么看懂关键的句就是input的上面那一段的第二行“The
Good_night_Sion_
·
2020-08-13 11:28
模拟
uva340 -
Master-Mind
Hints
MasterMindisagamefortwoplayers.Oneofthem,Designer,selectsasecretcode.Theother,Breaker,triestobreakit.Acodeisnomorethanarowofcoloreddots.Atthebeginningofagame,theplayersagreeuponthelengthNthatacodemust
滑头鬼之亨
·
2020-08-13 11:49
杂类
D -
Master-Mind
Hints
think:1题意先给出一个数字N代表之后每次输入的元素个数,每组输入数据的第一行代表目标集合,从第二行开始代表每次输入N个猜测元素与目标集合进行判断,1>判断同一下标对应的元素相等的个数(A),2>判断有多少个元素在两个集合中都出现过但是位置不对(B)2借鉴紫书:直接统计可得A,为了求B,对于每个数字(1~9),统计两者出现的次数c1和c2,则min(c1,c2)就是该数字对B的贡献。最后要减去
leoxry
·
2020-08-13 11:39
uva340
Master-Mind
Hints
题目:输入N个数字。然后再输入任意组N个数字。判断两个数字:1位置完全一致判断完1后2:位置不一致但是在两组中都存在注意:1我的想法主要是判断完后删除对应数字,听了同学思路发现根本不需要,因为数字范围是1~9,所以判断完置为0即可2在判断第二类数字,查找时,找到后及时break出for循环,否则会重复计算#include#include#include#include#include#includ
Harder_LZA
·
2020-08-13 10:14
uva
Master-Mind
Hints(思维)
MasterMindisagamefortwoplayers.Oneofthem,Designer,selectsasecretcode.Theother,Breaker,triestobreakit.Acodeisnomorethanarowofcoloreddots.Atthebeginningofagame,theplayersagreeuponthelengthNthatacodemust
头发茂盛有光泽
·
2020-07-08 22:11
暑期集训1
【ACM】UVA - 340
Master-Mind
Hints(一定要好好学英语...)
https://vjudge.net/problem/UVA-340N表示密码的个数第一行是正确的密码下面的行直到N个0之前,都是猜测的序列,输出的括号(A,B)A表示对应位置与密码相符合的个数,B表示出现在序列中的数字但是位置不对另设一个C表示两个序列中都出现的数字的个数(那么C只有两种情况,一个就是在对应位置上(即A),另一种就是不在对应位置上(即B))C=A+B输出的括号就可以转换成(A,C
__zzz__
·
2020-07-04 04:31
OJ
340 -
Master-Mind
Hints
Problem.png题目描述比较复杂,简单来说就是给一行答案序列,再给一行猜测序列,统计有多少数字是恰好对位匹配的(StrongMatch,A),有多少数字是两行里都有但是位置不同的(WeakMatch,B)。A的数目可以直接遍历一遍统计,而B的数目则需要对1-9每一个数,分别统计它们在答案序列和猜测序列里各出现多少次,取较小的那个值加给B。之所以取较小的值,是因为假设答案行有3个1,猜测行有5
不会积
·
2019-11-03 14:50
UVA340
Master-Mind
Hints【数组】
Master-MindHintsUVA-340题目传送门题目大意:先输入一个整数n,表示有n个数字,下面第一行代表正确答案,其下每一行代表用户猜的答案,需统计其有多少数字位置正确(A),有多少数字在两个字符串中都出现过但位置不正确(B),输入一全为0结束。AC代码:#include#include#include#include#include#include#include#include#in
无边星空
·
2018-11-04 09:21
紫书——数组与字符串(例题)
步于C++
算法竞赛入门经典(紫书)
UVa 340
Master-Mind
Hints
不知道他想干干嘛权当熟悉JAVAimportjava.util.Scanner; publicclassMain{ publicstaticvoidmain(Stringargs[]){ finalintmaxn=1000+9; Scannercin=newScanner(System.in); for(intt=1;;t++){ intn=cin.nextInt(); if(n==0)brea
YYecust
·
2016-05-03 17:00
340 -
Master-Mind
Hints
Master-MindHintsMasterMindisagamefortwoplayers.Oneofthem,Designer,selectsasecretcode.Theother,Breaker,triestobreakit.Acodeisnomorethanarowofcoloreddots.Atthebeginningofagame,theplayersagreeupontheleng
q547550831
·
2016-04-28 20:00
ACM
uva
UVa340
uva 340
Master-Mind
Hints
#include#includeusingnamespacestd;inta[1000],b[1000],c[10],d[10];intmain(){ intn; intkase=0; while(cin>>n&&n) { ++kase; for(inti=0;i>a[i]; cout>b[i]; if(b[i]==0)cnt++; }
qq_33901573
·
2016-04-10 18:00
UVA-340
Master-Mind
Hints (猜数字)
分析:猜数字游戏,水题 #include #include #include usingnamespacestd; constintN=1005; inta[N],b[N],c,d; intmain() { intn,cas=0; while(scanf("%d",&n),n) { mapaa; printf("Game%d:\n",++cas); for(inti=0;ibb; for
qq_32036091
·
2015-12-21 06:00
Master-Mind
UVA-340
UVa340 -
Master-Mind
Hints
题目地址:点击打开链接 C++代码: #include<iostream> #include<cstring> using namespace std; const int maxsize=2000; int main() { int a[maxsize],b[maxsize],flag_a[maxsize],flag_b[maxsize]
·
2015-11-13 15:45
master
UVa 340
Master-Mind
Hints (优化查找&复制数组)
340 -
Master-Mind
Hints Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?
·
2015-11-13 08:45
master
UVA340 -
Master-Mind
Hints
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=276 实在没读懂题意 搜的意思 真佩服UVA的表达能力 输入n,表示每个代码的长度为n;输入有多组数据,当n=0时表示结束;而在每组中,以最后输n个0结束。对于每组数据,第一行编码
·
2015-11-11 10:03
master
UVa 340
Master-Mind
Hints
蛋疼的题目描述,看了好长好长时间才看懂,题目本身是很简单的。 Designer给出一串长度为N的Code,Breaker用Guess来破译。 对于两串数字,如果有同一列相等的数字,那么叫做strong match, 位于不同列的相等的两个数字,叫做weak match。 题目要求就是先输出strong的个数,然后是weak的个数。 对了,需要注意的是 1、每个c
·
2015-11-02 11:22
master
UVa340(
Master-Mind
Hints)未完成
#include<stdio.h> int main() { int num,a[100],i,j,b[100]; while(scanf("%d",&num)!=EOF) { int s1=0,s2=0; for(i=0;i<num;i++) { scanf("%d",&a[i])
·
2015-11-01 15:51
master
UVA 340
Master-Mind
Hints 猜密码游戏(水)
题意:给一串密码(第一行),接着再给你很多行猜测,针对每行猜测,输出两个数字,分表代表:同一列上匹配的个数,不同列上匹配的个数。注:匹配指的是一次,一旦配对,不能再与其他配对。 思路:每接受一行猜测就匹配,扫一遍就知道哪些是同列匹配的,统计出来,作为第一个输出的数字。扫的过程中将同列匹配的guess列置为零,顺便将不匹配的secret列插进哈希可重复的set中。接着再扫一遍gue
·
2015-11-01 13:57
master
UVa-340
Master-Mind
Hints
#include<iostream> #include<cstdio> #include<cstring> #include<iomanip> using namespace std; int main() { //freopen("in.txt","r",stdin); //f
·
2015-10-27 14:32
master
Master-Mind
Hints
MasterMindisagamefortwoplayers.Oneofthem,Designer,selectsasecretcode.Theother,Breaker,triestobreakit.Acodeisnomorethanarowofcoloreddots.Atthebeginningofagame,theplayersagreeuponthelengthNthatacodemust
wsnbb123456789
·
2015-10-03 19:00
【白书之路】340 -
Master-Mind
Hints 数字统计
Master-MindHintsMasterMindisagamefortwoplayers.Oneofthem, Designer,selectsasecretcode.Theother, Breaker,triestobreakit.Acodeisnomorethanarowofcoloreddots.Atthebeginningofagame,theplayersagreeuponthele
wr132
·
2015-09-03 15:00
Hints
340
白书之路
Master-Mind
数字统计
UVA 340
Master-Mind
Hints
Master-MindHintsTimeLimit: 3000MS MemoryLimit: Unknown 64bitIOFormat: %lld&%lluSubmit StatusDescriptionMasterMindisagamefortwoplayers.Oneofthem, Designer,selectsasecretcode.Theother, Breaker,triestobr
qq_24653023
·
2015-08-24 17:00
ACM
uva
UVa340
Master-Mind
Hints
#include <stdio.h>#include <string.h>#define MIN(a,b) (((a) < (b)) ? (a) : (b))int main(){ int code[1000]; int guess[1000]; int C1[
·
2015-06-20 20:00
master
340 -
Master-Mind
Hints
Master-MindHints MasterMindisagamefortwoplayers.Oneofthem,Designer,selectsasecretcode.Theother,Breaker,triestobreakit.Acodeisnomorethanarowofcoloreddots.Atthebeginningofagame,theplayersagreeuponthelen
SD_Sunny_hui
·
2015-04-24 17:00
UVA - 340
Master-Mind
Hints
Master-MindHintsTimeLimit: 3000MS MemoryLimit: Unknown 64bitIOFormat: %lld&%lluSubmit StatusDescriptionMasterMindisagamefortwoplayers.Oneofthem, Designer,selectsasecretcode.Theother, Breaker,triestobr
qq_18738333
·
2015-03-17 18:00
UVa 340 -
Master-Mind
Hints
一个经典的猜数字游戏,本题交了一次就过了,但是调试花费了很大的功夫,一直也没找到原因,漏了几种情况,幸好在测试用例中找到了bug,调试了很久,用了3个goto语句,使得程序可能不容易被其他人理解吧,感觉这不是最简单的思路,应该再去看看别人的思路。 还有最重要的一点,读题一定要全面,详细,不要漏条件!!! #include#includeintmain(){ intm,n,i,j,k,r,s,t,
ft_sunshine
·
2015-01-30 15:00
UVa 340
Master-Mind
Hints
Master-MindHintsMasterMindisagamefortwoplayers.Oneofthem, Designer,selectsasecretcode.Theother, Breaker,triestobreakit.Acodeisnomorethanarowofcoloreddots.Atthebeginningofagame,theplayersagreeuponthele
axiqia
·
2015-01-17 22:00
Hints
Master-Mind
Uva 340
Master-Mind
Hints
A-Master-MindHintsTimeLimit:3000MS MemoryLimit:0KB 64bitIOFormat:%lld&%lluDescriptionMasterMindisagamefortwoplayers.Oneofthem,Designer,selectsasecretcode.Theother,Breaker,triestobreakit.Acodeisn
HelloWorld10086
·
2014-07-15 10:00
Hints
uva
Master-Mind
UVA 340 (暑假-排序、检索 -A -
Master-Mind
Hints)
#include #include intmain(){ constintMax=1050; intstr_1[Max],str_2[Max],str_3[Max]; intt=1,n; while(scanf("%d",&n),n){ //getchar(); printf("Game%d:\n",t++); //gets(str_1); for(inti=0;i
kl28978113
·
2014-07-12 10:00
uva 340 -
Master-Mind
Hints
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&page=show_problem&problem=276 C++AC。先遍历对比一遍得出strong的数量,然后对每个数字一次遍历weak的情况,一旦match之后都置为-1,以避免重复计算。#include const
jdflyfly
·
2014-06-24 20:00
uva 1548 - The Game of
Master-Mind
(dfs+剪枝)
题目链接:uva1548-TheGameofMaster-Mind题目大意:现在ACM公司要开发一个手游,游戏大致为猜数字,一开始给出p,c和m,p为要猜数字的个数,c为每个数字的最大上限,m为已经猜过的次数,每次猜完系统会给出相应的回复提示,所以接下来有2*m行为前m次的提示。每组提示分两行,一行是当前猜的数字分别有哪些,一行是代表说黑点个数和白点个数,所谓黑点个数即当前猜的数字有多少个与答案的
u011328934
·
2014-04-08 07:00
UVa 340 -
Master-Mind
Hints
在写这个程序之前,让我们先学习一下英语.╮(╯▽╰)╭Inthisproblemyouwillbegivenasecretcode andaguess ,andaretodeterminethehint.在这个问题中,你将会被提供一个密码s1....sn和一个猜测g1...gn,这将会决定暗示.Ahintconsistsofapairofnumbersdeterminedasfollows.一
u014247806
·
2014-03-30 18:00
ACM
uva
340
340 -
Master-Mind
Hints
340-Master-MindHints题目大意:计算列相同的数相同的个数,和不同的列相同的数,注意输出格式;解题思路:计算相同的数的对数,减去相同列的数相同的对数,剩下就是不同列的相同数的对数。#include #include constintN=1005; ints[N],s1[N]; intn,d[N],t=0; intcount,count1; intmain(){ inti,j;
u012997373
·
2013-12-20 21:00
uva 340
Master-Mind
Hints(检索)
Master-MindHints MasterMindisagamefortwoplayers.Oneofthem, Designer,selectsasecretcode.Theother, Breaker,triestobreakit.Acodeisnomorethanarowofcoloreddots.Atthebeginningofagame,theplayersagreeuponthe
u011328934
·
2013-07-28 14:00
340 -
Master-Mind
Hints
题意:猜数字,先输入一串secret,再输入一串guess,比较guess与secret中的每一位,若两个字母相同,且位置相同,则定义为strong;若字母相同,但位置不同,则定义为weak;最后输出strong与weak的对数.注:本来很简单的题目,由于理解错题意,想成需要从secret和guess里取最多的strong和weak对,结果一直没能AC. 思路:1.优先配对strong,把所有配对
sailtseng
·
2013-07-23 17:00
Hints
uva
MasterMind
340
排序/查找 340 -
Master-Mind
Hints
UVaOJRoot :: AOAPCI:BeginningAlgorithmContests(RujiaLiu) :: Volume1.ElementaryProblemSolving :: Sorting/Searching Master-MindHints MasterMindisagamefortwoplayers.Oneofthem, Designer,selectsasecretcode
SIOFive
·
2013-07-09 16:00
sort
searching
uva 340 -
Master-Mind
Hints
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&page=show_problem&problem=276 C++ AC。先遍历对比一遍得出strong的数量,然后对每个数字一次遍历weak的情况,一旦match之后都置为-1
249326109
·
2013-04-10 14:00
master
UVA 340 -
Master-Mind
Hints
这道题英文描述太冗余。最后看了有个小哥一句话描述的题意才明白了http://blog.163.com/kakarrot@yeah/blog/static/12011592520106241155854/。其实就是统计两个序列相同列相同数字的个数和不同列相同数字的个数。要注意,两列中任意一个元素如果已经用过就不能再用了。 由于只有9个数字,所以只需要统计每个数字出现的个数即
zcube
·
2013-01-03 18:00
统计
简单
UVaOJ 340 -
Master-Mind
Hints
AOAPCI: BeginningAlgorithmContests(RujiaLiu) :: Volume1.ElementaryProblemSolving ::Sorting/SearchingDescription很经典的MasterMind游戏,游戏规则已经被人熟知,只是游戏原型比较少人了解。游戏规则就是,由一个人出题,一个人解密。密码由N位1~9的数字组成。解密者不断提出猜测,出题人每
Ra_WinDing
·
2012-11-11 22:00
上一页
1
2
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他