B. Gerald is into Art
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Gerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought a special board to attach it to the wall and place the paintings on the board. The board has shape of ana1 × b1
rectangle, the paintings have shape of aa2 × b2 anda3 × b3
rectangles.

Since the paintings are painted in the style of abstract art, it does not matter exactly how they will be rotated, but still, one side of both the board, and each of the paintings must be parallel to the floor. The paintings can touch each other and the
edges of the board, but can not overlap or go beyond the edge of the board. Gerald asks whether it is possible to place the paintings on the board, or is the board he bought not large enough?

Input

The first line contains two space-separated numbers a1 andb1 — the sides of the board. Next two lines contain numbersa2, b2, a3
andb3 — the sides of the paintings. All numbersai, bi in the
input are integers and fit into the range from1 to
1000.

Output

If the paintings can be placed on the wall, print "YES" (without the quotes), and if they cannot, print "NO" (without the quotes).

Sample test(s)
Input
3 2
1 3
2 1
Output
YES
Input
5 5
3 3
3 3
Output
NO
Input
4 2
2 3
1 2
Output
YES
Note

That's how we can place the pictures in the first test:

And that's how we can do it in the third one.

题目要求把两幅画放到一块黑板上,要求两幅画不重叠不越界。所以能够先将一幅画放上去。在剩下的区域里面能够有两个位置去放,暴力枚举各种情况就可以。当中要注意第一幅画本身是否能放上去。

#include<stdio.h>
#include<string.h>
int main()
{
int a1,b1,a2,b2,a3,b3,i,j,k;
while(scanf("%d%d",&a1,&b1)!=EOF)
{
scanf("%d%d%d%d",&a2,&b2,&a3,&b3);
int x1=a1-a2;
int x2=a1-b2;
int y1=b1-b2;
int y2=b1-a2;
int f=0; if((x1>=a3&&b1>=b3&&b1>=b2)||(x1>=b3&&b1>=a3&&b1>=b2)){
printf("YES\n");continue;
}
if((y1>=b3&&a1>=a3&&a1>=a2)||(y1>=a3&&a1>=b3&&a1>=a2)){
printf("YES\n");continue;
}
if((x2>=a3&&b1>=b3&&b1>=a2)||(x2>=b3&&b1>=a3&&b1>=a2)){
printf("YES\n");continue;
}
if((y2>=a3&&a1>=b3&&a1>=b2)||(y2>=b3&&a1>=a3&a1>=b2)){
printf("YES\n");continue;
}
else printf("NO\n");
}
}
C. Gerald's Hexagon
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to.
Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it.

He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his
counting. Help the boy count the triangles.

Input

The first and the single line of the input contains 6 space-separated integersa1, a2, a3, a4, a5
anda6 (1 ≤ ai ≤ 1000) — the lengths of the sides of the hexagons in centimeters in the clockwise order. It
is guaranteed that the hexagon with the indicated properties and the exactly such sides exists.

Output

Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.

Sample test(s)
Input
1 1 1 1 1 1
Output
6
Input
1 2 1 2 1 2
Output
13
Note

This is what Gerald's hexagon looks like in the first sample:

And that's what it looks like in the second sample:

这个是数学题,推一下都能够推出来。题目大意,给定六边形的边长,要求算出当中有多少个等腰三角形。图形能够确定是由等腰三角形组成的。

假设画一绘图就能发现,假设将图形补成一个大的等腰三角形,那么小三角形的数目就是左側(或右側)三条边加起来以后的平方。由于对于一个边长为n 的等腰三角形来说。里面的小三角形是有n^2个的。所以题目中要求的三角形数量就是大的减去边上三个小的。

#include<stdio.h>
int s(int i)
{
return i*i;
}
int main()
{
int a[6],ans;
while(~scanf("%d",&a[0]))
{
for(int i=1;i<6;i++)
scanf("%d",&a[i]);
ans=a[0]+a[1]+a[2];
printf("%d\n",s(ans)-s(a[0])-s(a[2])-s(a[4]));
}
}
D. Equivalent Strings
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings
a and b of equal length are called
equivalent in one of the two cases:

  1. They are equal.
  2. If we split string a into two halves of the same size
    a1 and
    a2, and string
    b into two halves of the same size b1 and
    b2, then one of the following is correct:

    1. a1 is equivalent to
      b1, and
      a2 is equivalent to
      b2
    2. a1 is equivalent to
      b2, and
      a2 is equivalent to
      b1

As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent.

Gerald has already completed this home task. Now it's your turn!

Input

The first two lines of the input contain two strings given by the teacher. Each of them has the length from
1 to 200 000 and consists of lowercase English letters. The strings have the same length.

Output

Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise.

Sample test(s)
Input
aaba
abaa
Output
YES
Input
aabb
abab
Output
NO
Note

In the first sample you should split the first string into strings "aa" and "ba", the second one — into strings "ab" and "aa".
"aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab"
= "a" + "b", "ba" = "b" + "a".

In the second sample the first string can be splitted into strings "aa" and "bb", that are equivalent only to themselves. That's why string "aabb"
is equivalent only to itself and to string "bbaa".

题目大意:推断两个字符串是否“同样”。“同样”仅仅要满足下列条件之中的随意一个:

  1. They are equal.
  2. If we split string a into two halves of the same size
    a1 and
    a2, and string
    b into two halves of the same size b1 and
    b2, then one of the following is correct:

    1. a1 is equivalent to
      b1, and
      a2 is equivalent to
      b2
    2. a1 is equivalent to
      b2, and
      a2 is equivalent to
      b1

因为我拆分字符串的时候一定要等分,所以假设字符串是奇数的,直接strcmp比較就可以。

假设是偶数,那么久要拆分了。这里注意,我能够一直拆分直到被拆分的字符串变成奇数。

拆分过程中,假设有一组满足条件。那就满足条件了。所以能够调用递归函数。

#include<stdio.h>
#include<string.h>
char a[200005],b[200005];
bool panduan(char * s1,char *s2,int l)
{ if(strncmp(s1,s2,l)==0)return true; //这里用了strncmp函数。即比較s1,s2前l个字符是否同样。
if(l%2==1)return false;
int i,j;
/* char s3[100005],s4[100005];
char s5[100005],s6[100005];
for(i=0;i<l/2;i++)
{
s3[i]=s1[i];
s5[i]=s2[i];
}
for(i=l/2;i<l;i++)
{
s4[i-l/2]=s1[i];
s6[i-l/2]=s2[i];
}
*/ //这里的部分是我第一次写的时候T的代码,没实用strncmp函数。应该是由于递归调用过多,for循环用的也特别多。 if(panduan(s1,s2+l/2,l/2)&&panduan(s1+l/2,s2,l/2))return true;
if(panduan(s1,s2,l/2)&&panduan(s1+l/2,s2+l/2,l/2))return true; //注意这一行与上一行这题里面换不了,一换就T了。预计是数据问题。 //假设实在要换,能够手写strncmp函数。可能能够过,我没试过。 return false; }
int main()
{
int i,j,k,l;
while(scanf("%s%s",a,b)!=EOF)
{
l=strlen(a);
if(l%2==1){
if(strcmp(a,b)==0)printf("YES\n");
else printf("NO\n");
}
else {
if(panduan(a,b,strlen(a)))printf("YES\n");
else printf("NO\n");
}
}
}

codeforces #313(div 2)的更多相关文章

  1. Codeforces #344 Div.2

    Codeforces #344 Div.2 Interview 题目描述:求两个序列的子序列或操作的和的最大值 solution 签到题 时间复杂度:\(O(n^2)\) Print Check 题目 ...

  2. Codeforces #345 Div.1

    Codeforces #345 Div.1 打CF有助于提高做题的正确率. Watchmen 题目描述:求欧拉距离等于曼哈顿距离的点对个数. solution 签到题,其实就是求有多少对点在同一行或同 ...

  3. Codeforces Beta Round #27 (Codeforces format, Div. 2)

    Codeforces Beta Round #27 (Codeforces format, Div. 2) http://codeforces.com/contest/27 A #include< ...

  4. Codeforces#441 Div.2 四小题

    Codeforces#441 Div.2 四小题 链接 A. Trip For Meal 小熊维尼喜欢吃蜂蜜.他每天要在朋友家享用N次蜂蜜 , 朋友A到B家的距离是 a ,A到C家的距离是b ,B到C ...

  5. codeforces #592(Div.2)

    codeforces #592(Div.2) A Pens and Pencils Tomorrow is a difficult day for Polycarp: he has to attend ...

  6. codeforces #578(Div.2)

    codeforces #578(Div.2) A. Hotelier Amugae has a hotel consisting of 1010 rooms. The rooms are number ...

  7. codeforces #577(Div.2)

    codeforces #577(Div.2) A  Important Exam A class of students wrote a multiple-choice test. There are ...

  8. codeforces #332 div 2 D. Spongebob and Squares

    http://codeforces.com/contest/599/problem/D 题意:给出总的方格数x,问有多少种不同尺寸的矩形满足题意,输出方案数和长宽(3,5和5,3算两种) 思路:比赛的 ...

  9. Codeforces Round #313 (Div. 1)

    官方英文题解:http://codeforces.com/blog/entry/19237 Problem A: 题目大意: 给出内角和均为120°的六边形的六条边长(均为正整数),求最多能划分成多少 ...

随机推荐

  1. ajax的两种使用方式

    一.Ajax概述 1.什么是同步,什么是异步 同步现象:客户端发送请求到服务器端,当服务器返回响应之前,客户端都处于等待 卡死状态 异步现象:客户端发送请求到服务器端,无论服务器是否返回响应,客户端都 ...

  2. java中的hachcode方法

    哈希表这个数据结构想必大多数人都不陌生,而且在很多地方都会利用到hash表来提高查找效率.在Java的Object类中有一个方法: public native int hashCode(); 根据这个 ...

  3. Libvirt中windows虚拟机的动态内存管理

    非常短的前提 Libvirt支持对虚拟机进行内存动态扩展,可是windows虚拟机首先须要安装virtio-win驱动. KVM提供的virtio-win驱动下载地址: http://www.linu ...

  4. HDU5411CRB and Puzzle(矩阵高速幂)

    题目链接:传送门 题意: 一个图有n个顶点.已知邻接矩阵.问点能够反复用长度小于m的路径有多少. 分析: 首先我们知道了邻接矩阵A.那么A^k代表的就是长度为k的路径有多少个. 那么结果就是A^0+A ...

  5. WPF错误:必须使“Property”具有非 null 值。

    这个问题一般出如今Triggers中Property指定的类型为Nullable. 解决的方法就是用DataTrigger取代Trigger, 然后用Binding+Converter转换为详细非Nu ...

  6. Android解决ScrollView视图导致其底部的布局栏被推到上边的问题

    近期有个xml布局文件,我说下大概意思: <ScrollView> ...... </ScrollView> <RelativeLayout> ...... < ...

  7. windows上通过vnc连接虚拟机中linux系统

    首先要在虚拟机中安装vnc. 虚拟机的设置中要启用VNC连接. watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaHdzc2c=/font/5a6L5L2T/ ...

  8. python微框架Bottle(http)

    环境: win7系统 Python2.7 一 背景和概述 眼下项目中须要加入一个激活码功能,打算单独弄一个httpserver来写. 由于之前的游戏中已经有了一套完整的激活码生成工具和验证httpse ...

  9. HDU 5616 Jam's balance 背包DP

    Jam's balance Problem Description Jim has a balance and N weights. (1≤N≤20)The balance can only tell ...

  10. 仿写从iOS8开始支持的UIAlertController:BGAAlertController-Android

    工作以来公司UI设计师出的Android效果图都是iOS风格的UIAlertView和UIActionSheet,新项目还是用原来那一套,不想重复造轮子,所以仿写了从iOS8开始支持的UIAlertC ...