hdu - 1172 猜数字 (思维题)
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 猜数字 (思维题)的更多相关文章
- HDU 1172 猜数字 (模拟)
题目链接 Problem Description 猜数字游戏是gameboy最喜欢的游戏之一.游戏的规则是这样的:计算机随机产生一个四位数,然后玩家猜这个四位数是什么.每猜一个数,计算机都会告诉玩家猜 ...
- hdu 1172 猜数字
猜数字 Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- HDU 1172 猜数字(DFS)
猜数字 Time Limit:10000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
- hdu 1172 猜数字(暴力枚举)
题目 这是一道可以暴力枚举的水题. //以下两个都可以ac,其实差不多一样,呵呵 //1: //4 wei shu #include<stdio.h> struct tt { ],b[], ...
- HDU 2178.猜数字【分析能力练习】【读题能力练习】【8月10】
猜数字 Problem Description A有1数m.B来猜.B每猜一次,A就说"太大"."太小"或"对了" . 问B猜n次能够猜到的 ...
- [HDOJ] 1172.猜数字
Problem Description 猜数字游戏是gameboy最喜欢的游戏之一.游戏的规则是这样的:计算机随机产生一个四位数,然后玩家猜这个四位数是什么.每 猜一个数,计算机都会告诉玩家猜对几个数 ...
- HDOJ(HDU) 2178 猜数字(题意有点难理解、、、)
Problem Description A有1数m,B来猜.B每猜一次,A就说"太大","太小"或"对了" . 问B猜n次可以猜到的最大数. ...
- HDU 5752 Sqrt Bo (思维题) 2016杭电多校联合第三场
题目:传送门. 题意:一个很大的数n,最多开5次根号,问开几次根号可以得到1,如果5次还不能得到1就输出TAT. 题解:打表题,x1=1,x2=(x1+1)*(x1+1)-1,以此类推.x5是不超过l ...
- HDU 2178 猜数字
题解:设猜到的最大的数是h,在1到h间,你最多只要猜log2(h)+1(取整)次,所以易知==>h=2^m-1.即猜m次,能猜到的最大的数为2^m-1. #include <cstdio& ...
随机推荐
- 解决ef第一次启动较慢
protected void Application_Start() { //禁用第一次ef查询对表__MigrationHistory的问题使用了ef的Code first会在第一次ef查询的时候会 ...
- npm安装淘宝镜像cnpm报错npm ERR! errno -4048
今天在安装淘宝镜像的时候报错了,第一次遇上,表示很懵逼 然后捣腾了半天以为是npm install 的时候出错,后来网上查到是 装淘宝镜像cnpm的时候报错,好像是权限问题,解决方法: npm ca ...
- Objective -C Memory Management 内存管理 第一部分
Objective -C Memory Management 内存管理 第一部分 Memory management is part of a more general problem in pr ...
- struts2的action是线程安全的,struts1的action不是线程安全的真正原因
为什么struts2的action是线程安全的,struts1的action不是线程安全的? 先对struts1和struts2的原理做一个简单的讲解 对于struts1 ,当第一次**.do的请求过 ...
- vue热重载
依据官网使用 webpack 的 Hot Module Replacement API,Vuex 支持在开发过程中热重载 mutation.module.action 和 getter.你也可以在 B ...
- 田字格布局html div
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- swift class extension 与继承
1.扩展中无法继承重写已有函数,不能添加函数. Extensions can add new functionality to a type, but they cannot override exi ...
- 自动交互脚本之expect使用记录
之前一直没怎么用这个命令,意外用了一下,还不错,那这个是干嘛的呢 我们或多或少会远程登录其他服务器,需要执行某项任务,通常需要手动接入,输入密码啊,等等 那我们如何有效的自动执行呢,expect可以解 ...
- vs code 格式化 美化 html js css 插件 Beautify
安装 Beautify 插件 然后 F1 输入 Beautify file 回车即可
- webstorm 设置ES6语法支持以及添加vuejs开发配置
参考文章:https://blog.csdn.net/diligentkong/article/details/75040651