cccc第五次训练

这次的训练,看着看懂题了,可是真到写的时候又无从下手,,还是练得少啊。而且要挑会写的先写,,,,

这次从后往前写代码。。

K-CodeForces - 4A 

One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showedw kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.

Pete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight.

Input

The first (and the only) input line contains integer number w (1 ≤ w ≤ 100) — the weight of the watermelon bought by the boys.

Output

Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; andNO in the opposite case.

Example
Input
8
Output
YES
Note

For example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant — two parts of 4 and 4 kilos).

这一题,一看是英文题,题还那么长就不想做,其实呢,一点都不难,不过是拆分成两个偶数的数输出YES,否则输出NO。

#include<cstdio>
int main()
{
	int n;
	scanf("%d",&n);
	if(n%2==0&&n!=2)
	   printf("YES\n");
	else
	   printf("NO\n");
	return 0;
}
J-HDU - 2054 
Give you two numbers A and B, if A is equal to B, you should print "YES", or print "NO".
Input
each test case contains two numbers A and B.
Output
for each case, if A is equal to B, you should print "YES", or print "NO".
Sample Input
1 2
2 2
3 3
4 3
Sample Output
NO
YES
YES
NO
题目很简单,给你两个数,A,B,如果A==B,输出YES,否则输出NO。

但是这两个数有多大,这两个数是什么数,这些都要考虑,所以要开两个数组,然后把无用的0都删除,但是我最不熟悉的操作就是删零操作。。


I-HDU - 2089 

杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。
杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。
不吉利的数字为所有含有4或62的号码。例如:
62315 73418 88914
都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉利数字之列。
你的任务是,对于每次给出的一个牌照区间号,推断出交管局今次又要实际上给多少辆新的士车上牌照了。
Input
输入的都是整数对n、m(0<n≤m<1000000),如果遇到都是0的整数对,则输入结束。
Output
对于每个整数对,输出一个不含有不吉利数字的统计个数,该数值占一行位置。
Sample Input
1 100
0 0
Sample Output
80
这一题需要打个表,要不然会超时,,,

#include<cstdio>
int s[1000005];
void ff() 
{
	s[0]=s[1]=s[2]=s[3]=0;
	int n=1000005,num=0;
	for(int i=4;i<n;i++)
	{
		int m=i;
		while(m)
		{
			if(m%10==4||(m%10==2&&m/10%10==6))
			{
				num++;
				break;
			}  
			m/=10;
		}
		s[i]=num;
	}
}
int main()
{
	int n,m,num;
	ff();
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		if(n==0&&m==0)
		    break;
		num=m-n+1-(s[m]-s[n-1]);
		printf("%d\n",num);
	}
	return 0;
}

H-CodeForces - 114A 

When Petya went to school, he got interested in large numbers and what they were called in ancient times. For instance, he learned that the Russian word "tma" (which now means "too much to be counted") used to stand for a thousand and "tma tmyschaya" (which literally means "the tma of tmas") used to stand for a million.

Petya wanted to modernize the words we use for numbers and invented a word petricium that represents number k. Moreover,petricium la petricium stands for number k2, petricium la petricium la petricium stands for k3 and so on. All numbers of this form are calledpetriciumus cifera, and the number's importance is the number of articlesla in its title.

Petya's invention brought on a challenge that needed to be solved quickly: does some numberl belong to the set petriciumus cifera? As Petya is a very busy schoolboy he needs to automate the process, he asked you to solve it.

Input

The first input line contains integer number k, the second line contains integer numberl (2 ≤ k, l ≤ 231 - 1).

Output

You should print in the first line of the output "YES", if the number belongs to the setpetriciumus cifera and otherwise print "NO". If the number belongs to the set, then print on the seconds line the only number — the importance of numberl.

Example
Input
5
25
Output
YES
1
Input
3
8
Output
NO

显然题目长的题不一定复杂,题目短的题估计会不怎么简单,虽然英文题不好做,但是其实只是不想读题,看懂题意还蛮好做的。

这一题就是挺简单的,就看I是k的多少次方就行。。

#include<cstdio>
int main()
{
	int k,l;
	scanf("%d%d",&k,&l);
	int sum=0;
	while(l!=1)
	{
		if(l%k==0)
			sum++;
		else
		{
			sum=-1;
			break;
		} 
		l/=k;   	
	}
	if(sum==-1)
        printf("NO\n");
    else
        printf("YES\n%d\n",sum-1);
	return 0;
}

A-UVA - 674 

Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to makechanges with these coins for a given amount of money.For example, if we have 11 cents, then we can make changes with one 10-cent coin and one 1-centcoin, two 5-cent coins and one 1-cent coin, one 5-cent coin and six 1-cent coins, or eleven 1-cent coins.So there are four ways of making changes for 11 cents with the above coins. Note that we count thatthere is one way of making change for zero cent.Write a program to find the total number of different ways of making changes for any amount ofmoney in cents. Your program should be able to handle up to 7489 cents.

Input

The input file contains any number of lines, each one consisting of a number for the amount of moneyin cents.

Output

For each input line, output a line containing the number of different ways of making changes with theabove 5 types of coins.

Sample Input

11

26

Sample Output

4

13

这一题没想到可以用递推,虽然也可以用记忆化搜索,但是我更熟悉递推,真的没有想到,不过看了一眼别人的代码就恍然大悟的赶脚,天哪。

#include<cstdio>
int coin[5]={1,5,10,25,50};
int d[8000]={1};
int main()
{
	for(int i=0;i<5;i++)
	   for(int j=0;j<8000-100;j++)
	      d[j+coin[i]]+=d[j];
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		printf("%d\n",d[n]);
	}
	return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值