http://acm.hdu.edu.cn/showproblem.php?pid=1172

这个题换一种想法,可以找出四位数中所有满足条件的数看是否只有一个.

 #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <string>
#include <set>
#include <functional>
#include <numeric>
#include <sstream>
#include <stack>
#include <map>
#include <queue>
#pragma comment(linker, "/STACK:102400000,102400000")
#define CL(arr, val) memset(arr, val, sizeof(arr)) #define ll long long
#define inf 0x7f7f7f7f
#define lc l,m,rt<<1
#define rc m + 1,r,rt<<1|1
#define pi acos(-1.0) #define L(x) (x) << 1
#define R(x) (x) << 1 | 1
#define MID(l, r) (l + r) >> 1
#define Min(x, y) (x) < (y) ? (x) : (y)
#define Max(x, y) (x) < (y) ? (y) : (x)
#define E(x) (1 << (x))
#define iabs(x) (x) < 0 ? -(x) : (x)
#define OUT(x) printf("%I64d\n", x)
#define lowbit(x) (x)&(-x)
#define Read() freopen("a.txt", "r", stdin)
#define Write() freopen("b.txt", "w", stdout);
#define maxn 1000000000
#define N 2510
#define mod 1000000000
using namespace std; struct point
{
int x,y,z;
}p[]; bool judge(int n,int m)
{
int a[],b[],used[];
a[]=n/,a[]=n/%,a[]=n/%,a[]=n%;
b[]=p[m].x/,b[]=p[m].x/%,b[]=p[m].x/%,b[]=p[m].x%;
// for(int i=0;i<4;i++)
// printf("%d ",b[i]);
//printf("\n");
int ans=;
for(int i=;i<;i++)
{
if(a[i]==b[i]) ans++;
}
// printf("%d\n",ans);
if(ans!=p[m].z) return false;
ans=;
memset(used,,sizeof(used));
for(int i=;i<;i++)
for(int j=;j<;j++)
if(!used[j]&&a[i]==b[j])
{
ans++;
used[j]=;
//printf("%d %d\n",a[i],b[j]);
break;
}
// printf("%d\n",ans);
if(ans!=p[m].y) return false;
return true;
}
int main()
{
//freopen("a.txt","r",stdin);
int n;
while(~scanf("%d",&n)&&n)
{
for(int i=;i<n;i++) scanf("%d%d%d",&p[i].x,&p[i].y,&p[i].z);
int ans=,cnt=;
for(int i=;i<=;i++)
{
bool flag=;
for(int j=;j<n;j++)
if(!judge(i,j)) {flag=;break;}
if(!flag) {ans++;cnt=i;}
}
// printf("%d\n",ans);
if(ans==) printf("%d\n",cnt);
else printf("Not sure\n");
}
return ;
}

hdu - 1172 猜数字 (思维题)的更多相关文章

  1. HDU 1172 猜数字 (模拟)

    题目链接 Problem Description 猜数字游戏是gameboy最喜欢的游戏之一.游戏的规则是这样的:计算机随机产生一个四位数,然后玩家猜这个四位数是什么.每猜一个数,计算机都会告诉玩家猜 ...

  2. hdu 1172 猜数字

    猜数字 Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  3. HDU 1172 猜数字(DFS)

    猜数字 Time Limit:10000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  4. hdu 1172 猜数字(暴力枚举)

    题目 这是一道可以暴力枚举的水题. //以下两个都可以ac,其实差不多一样,呵呵 //1: //4 wei shu #include<stdio.h> struct tt { ],b[], ...

  5. HDU 2178.猜数字【分析能力练习】【读题能力练习】【8月10】

    猜数字 Problem Description A有1数m.B来猜.B每猜一次,A就说"太大"."太小"或"对了" . 问B猜n次能够猜到的 ...

  6. [HDOJ] 1172.猜数字

    Problem Description 猜数字游戏是gameboy最喜欢的游戏之一.游戏的规则是这样的:计算机随机产生一个四位数,然后玩家猜这个四位数是什么.每 猜一个数,计算机都会告诉玩家猜对几个数 ...

  7. HDOJ(HDU) 2178 猜数字(题意有点难理解、、、)

    Problem Description A有1数m,B来猜.B每猜一次,A就说"太大","太小"或"对了" . 问B猜n次可以猜到的最大数. ...

  8. HDU 5752 Sqrt Bo (思维题) 2016杭电多校联合第三场

    题目:传送门. 题意:一个很大的数n,最多开5次根号,问开几次根号可以得到1,如果5次还不能得到1就输出TAT. 题解:打表题,x1=1,x2=(x1+1)*(x1+1)-1,以此类推.x5是不超过l ...

  9. HDU 2178 猜数字

    题解:设猜到的最大的数是h,在1到h间,你最多只要猜log2(h)+1(取整)次,所以易知==>h=2^m-1.即猜m次,能猜到的最大的数为2^m-1. #include <cstdio& ...

随机推荐

  1. .net 发送邮件验证码

    using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Net.Ma ...

  2. 为什么jfinal的控制器不用单例模式

    先假controller定采用单例模式,通常两种设计方式来存放 HttpServletRequest.HttpServletResponse 等对象,一是利用一个类似于 ActionContext 的 ...

  3. jquery日期控件+时分秒

    因为项目需要,一些时间上的查询要精确的时分.先看下效果图吧. 所需要的js 跟css 文件 jsp://特别注意引入的先后顺序 <link rel="stylesheet" ...

  4. Flex 布局 (两个div居中自适应 宽度变小变一列,宽度够就是两列)

    https://www.runoob.com/w3cnote/flex-grammar.html display: flex; justify-content: center; align-items ...

  5. Zend Studio / Eclipse 缩进设置

    首先是Window – Preferences打开Preferences配置对话框: 然后依次找到PHP – Code Style – Formatter,如下图所示: 这里注意一下Active pr ...

  6. 单文件组件.vue---父子组件通信

    每一个.vue 文件就是一个 组件,组件和组件相互组合,就成了一个应用,这就涉及到的组件和组件之间的通信,最常用的就是父子之间的通信.在vue 中, 在一个组件中通过 import 引入另一个组件,这 ...

  7. js模拟输入支付密码

    html <div class="content"> <!--<div class="title">支付宝支付密码:</di ...

  8. ansible中yaml语法应用

    4.yaml语法应用 ansible的playbook编写是yaml语言编写,掌握yaml语法是编写playbook的必要条件,格式要求和Python相似,具体教程参考如下 yaml语言教程 附上一个 ...

  9. python send email

    #!/usr/bin/python # -*- coding: UTF-8 -*- # coding:utf8 from smtplib import SMTP_SSL from email.head ...

  10. 四、spring中高级装配(2)

    这个是接着上一篇写的,这章内容较多,分开来记录一下... 三.处理自动装配的歧义性 自动装配让spring完全负责bean引用注入到构造参数和属性中,不过,仅有一个bean匹配所需的结果时,自动装配才 ...