SZU 2015 Winter Training Day#4

1 篇文章 0 订阅

Problem(A15):TripleFree

Judge Info

Memory Limit: 32768KB

Case Time Limit: 10000MS

Time Limit: 10000MS

Judger: Normal

Description

Who can be the king in the kingdom of frogs?The one who can solve this problem in the shortest time. So, what’s theproblem? The problem named as Triple-Free- Or-Not. You are given a list ofinteger, you are asked to tell if the list is triple free or not. Triple freemeans, no 3 integers in the list can form an increasing arithmetic sequence(asequence of numbers such that the difference of any two successive members is apositive constant). The old king wants to keep the position, he is asking yourhelp.

Task

You are given a list of integer numbers,write a program which can tell if it is triple free or not.

Input

The first line of input contains T(1 \leq T\leq 100), the number of test cases. The first line of each test case will havean integer number N(1 \leq N \leq 1, 000), the number of integers in the list.The second line will contain N integers separate by spaces, all of them are inthe range of [-2^{31},2^{31}-1]\,.

Output

For each test case, print Triple-Free orTriple-NotFree in one line.

Sample Input

2

3

1 2 3

3

3 4 6

Sample Output

Triple-NotFree

Triple-Free

 

程序:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int mod=10000;
const int MAXN=10000+5;

vector<int> point[MAXN];

int main()
{
	int t,i,j,k,n,a[1005],line,pos,len;
	long long temp;
	memset(a,0,sizeof(a));

	scanf("%d",&t);
	while (t--)
	{
		for (i=0;i<MAXN;i++)
			point[i].clear();

		scanf("%d",&n);
		for (i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
			point[abs(a[i])%mod].push_back(a[i]);
		}

		sort(a,a+n);
		for (i=0;i<n;i++)
			for (j=i+1;j<n;j++)
			{	
				temp=2*a[j]-a[i];
				line=abs(temp)%mod;
				len=point[line].size();

				if (!len) continue;
				for (k=0;k<len;k++)
					if (temp==point[line][k]) break;
				if (k<len)
				{
					b2:
					printf("Triple-NotFree\n");
					goto b1;
				}
			}

		printf("Triple-Free\n");

		b1:;
	}

	return 0;
}

Problem(A41):Numbers

Judge Info

Memory Limit: 32768KB

Case Time Limit: 31000MS

Time Limit: 60000MS

Judger: Normal

Description

Let’s play a game about numbers. The rule ofthis game is quite simple. Only two kinds of commands in this game, one is’Add\, k\,’ command the other one is ’Ask\,

k\,’ command. You will have a list ofnumbers. At beginning the list is empty. When you got the command ’Add\, k’,firstly, you must check if the number k\, is in the list or not; secondly, ifthe number k\, is not in the list, add it to the list or do nothing. When yougot the command ’Ask\, k’ you should tell if the number in the list or not.

Task

Please code a program for me, which can helpme to play this game.

Input

The first line of input contains T(1 \leq T\leq 20), the number of test cases. The first line of each test case will havean integer number N(1 \leq N \leq 1, 000, 000), the number of commands. N\,lines followed, each contains one command 'Add\, k' or 'Ask\, k'(-\,2,000,000,000 \leq k \leq 2,000,000,000).

Hint for C++ users: Huge input, do not usecin.

Output

For each ’Ask\, k’ command, print ’YES\,’when the number k\, in the list or print ’NO\,’ in one line.

Sample Input

2

5

Add 2

Ask 3

Ask 2

Add 3

Ask 3

2

Add 1

Ask 2

Sample Output

NO

YES

YES

NO

 

程序:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

const int mod=10000;
const int MAXN=10000+5;

vector<int> point[MAXN];

int main()
{
	int n,temp,t1,line,i,len;
	bool pos;
	char s[5];

	scanf("%d",&t1);

	while (t1--)
	{
		for (i=0;i<MAXN;i++)
			point[i].clear();

		scanf("%d",&n);
		while (n--)
		{
			scanf("%s",&s);
			scanf("%d",&temp);
			
			line=abs(temp%mod);
			len=point[line].size();

			pos=false;
			for (i=0;i<len;i++)
				if (temp==point[line][i])
				{
					pos=true;
					break;
				}
			
			if (!strcmp(s,"Add"))
			{
				if (!pos)
					point[line].push_back(temp);
			}
			else
			{
				if (pos)
					printf("YES\n");
				else
					printf("NO\n");
			}
		}
	}

	return 0;
}

Problem(B40):Fengshui

Judge Info

Memory Limit: 32768KB

Case Time Limit: 10000MS

Time Limit: 30000MS

Judger: Normal

Description

Fengshui is an ancient subject in Chinesetradition. Someone considers it as science and someone criticizes it as blindfaith. Who knows! However, in modern days, everyone should respect culture fromour ancestor!

Fengshui focus on geography,environment andstaffs' position, all the theory come from a very old book named"YI". YI means change. Everything is always changing in the world.Fengshui wishes to guide changing, make life change to a better situation. Nowlet's look at Fengshui's changing.

At first we must know about the traditionalfive elements system which composed by GOLD,WOOD,GROUND,WATER and FIRE.Everything in the world can be represented by one and only one element. Forexample, river is represented by WATER, hill is represented by GROUND. Here, weonly consider the elements. In this system, once element can kill anotherelement, and one element can born anther element. Five elements compose as acircuit, as in Figure 1.

Every place has eight direction - east, west,north, south, northeast, northwest, southeast and southwest. Every directionhas a represented element. Now, our problem is about the elements at theseeight directions which form a Fengshui situation. Figure 2 is an example of oneFengshui situation.

But Fengshui situation can change! There'retwo change ways:

TURN: The whole situation turn clockwise onestep. Figure 3 shows the situation that situation in Figure 2 makes one TURNchange.

REBORN: Based on kill and born relation, onedirection's element can be killed by another direction's (at any other place)element in the situation, and then the killed element will born out as the newelement at its direction. Of course, kill and born are all according as therelation of the system as in Figure 1. In situation of Figure 3, WATER in eastcan kill FIRE in southeast, then southeast place change to be GROUND, as inFigure 4.

Each change, no matter TURN or REBORN, constone step.

Now, there're two Fengshui situation, wewant to know is it possible that first one can change to the second one? And ifpossible, how many steps it need at least?

Input

There're several cases, the first line ofinput is the number of cases. Every case includes 6 lines, the first 3 linesindeicate the first Fengshui situation, the last 3 lines incicate the secondFengshui situation.

The format of one situation is as follow,there may be arbitrary blanks between adjacent directions.

northwest north  northeast

west                   east

southwest south  southeast

Output

For every case, output the number of theleast changing steps on a single line, if it is possible, or output -1.

Sample Input

2

GOLD WOOD WATER

WATER    FIRE

WOOD GOLD GROUND

WATER GOLD WOOD

WOOD      WATER

GOLD GROUND GROUND

WATER GROUND WOOD

GOLD        FIRE

GOLD FIRE   GROUND

GOLD FIRE   FIRE

GOLD        FIRE

WATER GROUND WOOD

Sample Output

2

14





Problem(B61):Games

Judge Info

Memory Limit: 32768KB

Case Time Limit: 10000MS

Time Limit: 10000MS

Judger: Normal

Description

Let's play a game like Problem A41 again.The rule of this game is quite simple. Only three kinds of commands in thisgame,  'Add \, k\,' , 'Ask \, k\,' and'Del \, k\,'. You will have a list of numbers. At beginning the list is empty.When you got the command 'Add \, k', firstly, you must check if the number 'k',is in the list or not; secondly, if the number 'k', is not in the list, add itto the list or do nothing. When you got the command 'Ask \, k' you should tellif the number in the list or not. When you got the command 'Del\, k', firstly,you must check if the number 'k', is in the list or not; secondly, if thenumber 'k', is in the list, delete it from the list or do nothing.

Input

The first line of input contains T \,, thenumber of test cases. The first line of each test case will have an integernumber N(1 \leq N \leq 1, 000, 000), the number of commands. N \, linesfollowed, each contains one command 'Add \, k' , 'Ask \, k' and 'Del \, k'. Forevery k \, fited in 32 \,-bit.

Output

For each 'Ask \, k' command, print 'YES \,'when the number k \, in the list or print 'NO \,' in one line.

Sample Input

2

5

Add 2

Ask 3

Ask 2

Del 2

Add 3

2

Del 2

Ask 1

Sample Output

NO

YES

NO



程序:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

const int mod=10000;
const int MAXN=10000+5;

vector<long long> point[MAXN];

int main()
{
	int n,temp,t1,line,i,len;
	bool pos;
	char s[5];

	scanf("%d",&t1);

	while (t1--)
	{
		for (i=0;i<MAXN;i++)
			point[i].clear();

		scanf("%d",&n);
		while (n--)
		{
			scanf("%s",&s);
			scanf("%d",&temp);
			
			line=abs(temp%mod);
			len=point[line].size();

			pos=false;
			for (i=0;i<len;i++)
				if (temp==point[line][i])
				{
					pos=true;
					break;
				}
			
			if (!strcmp(s,"Add"))
			{
				if (!pos)
					point[line].push_back(temp);
			}
			else
			if (!strcmp(s,"Ask"))
			{
				if (pos)
					printf("YES\n");
				else
					printf("NO\n");
			}
			else
			{
				if (pos)
					point[line][i]=3000000000;
			}
		}
	}

	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
系统根据B/S,即所谓的电脑浏览器/网络服务器方式,运用Java技术性,挑选MySQL作为后台系统。系统主要包含对客服聊天管理、字典表管理、公告信息管理、金融工具管理、金融工具收藏管理、金融工具银行卡管理、借款管理、理财产品管理、理财产品收藏管理、理财产品银行卡管理、理财银行卡信息管理、银行卡管理、存款管理、银行卡记录管理、取款管理、转账管理、用户管理、员工管理等功能模块。 文中重点介绍了银行管理的专业技术发展背景和发展状况,随后遵照软件传统式研发流程,最先挑选适用思维和语言软件开发平台,依据需求分析报告模块和设计数据库结构,再根据系统功能模块的设计制作系统功能模块图、流程表和E-R图。随后设计架构以及编写代码,并实现系统能模块。最终基本完成系统检测和功能测试。结果显示,该系统能够实现所需要的作用,工作状态没有明显缺陷。 系统登录功能是程序必不可少的功能,在登录页面必填的数据有两项,一项就是账号,另一项数据就是密码,当管理员正确填写并提交这二者数据之后,管理员就可以进入系统后台功能操作区。进入银行卡列表,管理员可以进行查看列表、模糊搜索以及相关维护等操作。用户进入系统可以查看公告和模糊搜索公告信息、也可以进行公告维护操作。理财产品管理页面,管理员可以进行查看列表、模糊搜索以及相关维护等操作。产品类型管理页面,此页面提供给管理员的功能有:新增产品类型,修改产品类型,删除产品类型。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值