B Have a Nice Day



Problem B: B Have a Nice Day

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 136   Solved: 40
[ Submit][ Status][ Web Board]

Description

Problem 
        Rumour has it that the P versus N P  question has been solved:  the two classes are not equal.  This 
implies  that  many  well-known  problems,  such  as  the  Traveling  Salesman  Problem,  will  remain 
difficult  forever.   It  can  be  considered  a  waste  of  time  to  search  for  polynomial  time  solutions: 
essentially only brute-force approaches can solve them.  Nothing you can do about that. 
    In  view  of  the  international  crisis,  the  new  Dutch  government  has  therefore  announced  that 
on  certain  days  it  is  not  allowed  to  work  on  these  hard  problems  anymore.  Instead,  one  must 
concentrate  on  easier  issues.   These  days  are  called  nice.   Of  course,  the  algorithm  to  decide 
whether a given date is nice or not should itself be easy.  So far politicians could not find such an 
algorithm.  Can you? 
    A  date  day month year is  written  down  using  the  digits  0,. . . ,9. A  date  is  called  nice if  the 
digits occurring in it occur an equal number of times,  and if it can be  split.       A date can be split 
if its four number set can be divided into two disjoint subsets with equal sum; the four numbers 
are the day, the month, the left part of the year (the number represented by its first and second 
digit; for 1957 this is 19) and the right part of the year (the number represented by its third and 
fourth  digit;  for  2000  this  is  0). For  example,  16  5  4928  is  nice,  because  all  digits  occur  exactly 
once and  16 + 5 + 28 = 49. 

Input

        The first line of the input contains a single number:  the number of test cases to follow.  Each test 
case has the following format: 
    •  One line with three integers D, M and Y  separated by single spaces, satisfying 1 ≤ D ≤ 31, 
       1 ≤ M ≤ 12 and  1000 ≤ Y  ≤ 9999:        the day,  month and year of a valid date,  respectively. 

Output

       For  every  test  case  in  the  input,  the  output  should  contain  the  string "yes" or  "no":  the  fact 
whether the date is nice or not. 

Sample Input

4
16 5 4928
14 12 2747
11 11 1111
3 3 2014

Sample Output

yes
no
yes
no

HINT

此题昨晚甚是纠结。。。。。。今天看了大神的代码,恍然大悟!!!!!!
只怪自己太弱。。。。
题意:给你三个数:day,month,year(左右各取两位,分成左右两个数)要求这四个数出现的次数相等,而且任意两个数相加等于另外两个数相加或者任意三个数相加等于另外一个数。
#include<stdio.h>
#include<string.h>
int digs[10];
void countdigs(int x)
{
	while(x)
	{
		x%=10;
		digs[x]++;
		x/=10;
	}
}
bool solve(int a,int b,int c,int d)
{
	return a == b + c + d || a + b == c + d || a + c == b + d || a + d == b + c || a + b + c == d || a + b + d == c || a + c + d == b;
}
int main()
{
	int t,d,m,y;
	scanf("%d",&t);
	while(t--)
	{
		memset(digs,0,sizeof(digs));
		scanf("%d%d%d",&d,&m,&y);
		countdigs(d);
		countdigs(m);
		countdigs(y);
		for(int i=0;i<10;i++)
		for(int j=0;j<10;j++)
		{
			if(digs[i]>0&&digs[j]>0&&digs[i]!=digs[j])
			{
				printf("no\n");
				return 0;
			}
		}
		if(solve(d,m,y/100,y%100))
		printf("yes\n");
		else printf("no\n");	
	}
	return 0;
} 


资源下载链接为: https://pan.quark.cn/s/22ca96b7bd39 在 IT 领域,文档格式转换是常见需求,尤其在处理多种文件类型时。本文将聚焦于利用 Java 技术栈,尤其是 Apache POI 和 iTextPDF 库,实现 doc、xls(涵盖 Excel 2003 及 Excel 2007+)以及 txt、图片等格式文件向 PDF 的转换,并实现在线浏览功能。 先从 Apache POI 说起,它是一个强大的 Java 库,专注于处理 Microsoft Office 格式文件,比如 doc 和 xls。Apache POI 提供了 HSSF 和 XSSF 两个 API,其中 HSSF 用于读写老版本的 BIFF8 格式(Excel 97-2003),XSSF 则针对新的 XML 格式(Excel 2007+)。这两个 API 均具备读取和写入工作表、单元格、公式、样式等功能。读取 Excel 文件时,可通过创建 HSSFWorkbook 或 XSSFWorkbook 对象来打开相应格式的文件,进而遍历工作簿中的每个 Sheet,获取行和列数据。写入 Excel 文件时,创建新的 Workbook 对象,添加 Sheet、Row 和 Cell,即可构建新 Excel 文件。 再看 iTextPDF,它是一个用于生成和修改 PDF 文档的 Java 库,拥有丰富的 API。创建 PDF 文档时,借助 Document 对象,可定义页面尺寸、边距等属性来定制 PDF 外观。添加内容方面,可使用 Paragraph、List、Table 等元素将文本、列表和表格加入 PDF,图片可通过 Image 类加载插入。iTextPDF 支持多种字体和样式,可设置文本颜色、大小、样式等。此外,iTextPDF 的 TextRenderer 类能将 HTML、
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值