poj 1013 Counterfeit Dollar

Counterfeit Dollar
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 36273 Accepted: 11583

Description

Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are true silver dollars; one coin is counterfeit even though its color and size make it indistinguishable from the real silver dollars. The counterfeit coin has a different weight from the other coins but Sally does not know if it is heavier or lighter than the real coins. 
Happily, Sally has a friend who loans her a very accurate balance scale. The friend will permit Sally three weighings to find the counterfeit coin. For instance, if Sally weighs two coins against each other and the scales balance then she knows these two coins are true. Now if Sally weighs 
one of the true coins against a third coin and the scales do not balance then Sally knows the third coin is counterfeit and she can tell whether it is light or heavy depending on whether the balance on which it is placed goes up or down, respectively. 
By choosing her weighings carefully, Sally is able to ensure that she will find the counterfeit coin with exactly three weighings.

Input

The first line of input is an integer n (n > 0) specifying the number of cases to follow. Each case consists of three lines of input, one for each weighing. Sally has identified each of the coins with the letters A--L. Information on a weighing will be given by two strings of letters and then one of the words ``up'', ``down'', or ``even''. The first string of letters will represent the coins on the left balance; the second string, the coins on the right balance. (Sally will always place the same number of coins on the right balance as on the left balance.) The word in the third position will tell whether the right side of the balance goes up, down, or remains even.

Output

For each case, the output will identify the counterfeit coin by its letter and tell whether it is heavy or light. The solution will always be uniquely determined.

Sample Input

1 
ABCD EFGH even 
ABCI EFJK up 
ABIJ EFGH even 

Sample Output

K is the counterfeit coin and it is light. 

Source


假币

Time Limit: 1000MS

Memory Limit: 10000K

Total Submissions: 36273

Accepted: 11583

Description

Sally Jones有一打银币(12个)。然而,只有11个硬币是真的银币;有一个假币颜色和形状都跟真的一样。假的这个只有重量和真的不一样,不过Sally搞不清楚假的是轻了还是重了。

令人欣喜的是,Sally有一个朋友借给她了一个碉堡了的天平。她的朋友允许她称量三次来找到假币,如果Sally两边各放一枚银币,如果天平平衡了,说明这2个全真的,然后Sally拿一个真的和第三个各放一边,如果天平没平衡,则Sally知道这第三个硬币是假的,并且知道这枚假币是轻了还是重了。

通过合理的承重,她认为可以在三次称重中找到假币。

Input

第一行输入一个n(n>0)说明一共有多少组数据。每一组数据包含三行输入,包括一次称重过程。Sally已经将所有的银币标记为A—L。每次的称重信息包含两个由字母组成的字符串和一个单词“up”,”down”,或者”even”。第一串字母表示天平左面的银币;第二串字母表示天平右面的银币。(Sally每次将在左面和右面放等量的银币。)占据第三个位置的那个单词江表示右边盘子内的银币相对于左边盘子是沉了,轻了,还是一样重

Output

对于每一组数据,输出包括假币对应的字母,和他的重量(轻了还是重了)结果总是单一的

Sample Input

1

ABCD EFGH even

ABCI EFJK up

ABIJ EFGH even

Sample Output

K is the counterfeit coin and it is light.

Source

East Central North America 1998

 

这道题算逻辑推理么.....额,感觉更像个模拟,其实就是如果两边平衡那就肯定都是真的没跑了,就都强制写上:真!。然后如果有重量差别,那左右哪个都有可能是假的,那就打个标记,重的一边加一,轻的一边减一。
感觉想的有点太简单了,没想到真过了= =
中间忽略一些细节,这个左右放的数量是一样的,但是放多少个不是固定的....俺还以为是固定4个...结果交了次w。。。。。

#include<iostream>
#include<cmath>
#include<algorithm>
#include <stdio.h>
#include <string.h>

int main(void)
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
	int n;
	scanf("%d", &n);
//	printf("%d", n);
	while(n--)
	{

//	    printf("%d", k);
		char left[14]={0}, right[14]={0}, weight[5]{0};
		int distrust[14] = {0};
		int trust[14] = {0};
		for (int j = 0;j < 3;j ++)
		{
			scanf("%s%s%s", left, right, weight);
//			printf("%s %s %s\n", left, right, weight);
			if (weight[0] == 'e')
			{
				for (int i = 0;i < strlen(left);i ++)
				{
					trust[left[i] - 'A'] = 1;
					trust[right[i] - 'A'] = 1;
				}
			}
			if (weight[0] == 'u')
			{
				for (int i = 0;i < strlen(left);i ++)
				{
					distrust[left[i] - 'A']--;
					distrust[right[i] - 'A']++;
				}
			}
			if (weight[0] == 'd')
			{
				for (int i = 0;i < strlen(left);i ++)
				{
					distrust[left[i] - 'A']++;
					distrust[right[i] - 'A']--;
				}
			}
		}
		int maxdis = -1;
		int maxreal = -1;
		for (int i = 0;i < 12;i ++)
		{
//		    printf("%d ", distrust[i]);
            if (trust[i]) continue;
			if (abs(distrust[i]) > maxdis)
			{
				maxdis = abs(distrust[i]);
				maxreal = i;
			}
		}
		if (distrust[maxreal] > 0)
			printf("%c is the counterfeit coin and it is light.\n",  maxreal + 'A');
		else printf("%c is the counterfeit coin and it is heavy.\n",  maxreal + 'A');
	}
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
智慧校园整体解决方案是响应国家教育信息化政策,结合教育改革和技术创新的产物。该方案以物联网、大数据、人工智能和移动互联技术为基础,旨在打造一个安全、高效、互动且环保的教育环境。方案强调从数字化校园向智慧校园的转变,通过自动数据采集、智能分析和按需服务,实现校园业务的智能化管理。 方案的总体设计原则包括应用至上、分层设计和互联互通,确保系统能够满足不同用户角色的需求,并实现数据和资源的整合与共享。框架设计涵盖了校园安全、管理、教学、环境等多个方面,构建了一个全面的校园应用生态系统。这包括智慧安全系统、校园身份识别、智能排课及选课系统、智慧学习系统、精品录播教室方案等,以支持个性化学习和教学评估。 建设内容突出了智慧安全和智慧管理的重要性。智慧安全管理通过分布式录播系统和紧急预案一键启动功能,增强校园安全预警和事件响应能力。智慧管理系统则利用物联网技术,实现人员和设备的智能管理,提高校园运营效率。 智慧教学部分,方案提供了智慧学习系统和精品录播教室方案,支持专业级学习硬件和智能化网络管理,促进个性化学习和教学资源的高效利用。同时,教学质量评估中心和资源应用平台的建设,旨在提升教学评估的科学性和教育资源的共享性。 智慧环境建设则侧重于基于物联网的设备管理,通过智慧教室管理系统实现教室环境的智能控制和能效管理,打造绿色、节能的校园环境。电子班牌和校园信息发布系统的建设,将作为智慧校园的核心和入口,提供教务、一卡通、图书馆等系统的集成信息。 总体而言,智慧校园整体解决方案通过集成先进技术,不仅提升了校园的信息化水平,而且优化了教学和管理流程,为学生、教师和家长提供了更加便捷、个性化的教育体验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值