http://codeforces.com/contest/452/problem/B
 
B. 4-point polyline
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touching. This polyline should be as long as possible.

A polyline defined by points p1, p2, p3, p4 consists of the line segments p1 p2, p2 p3, p3 p4, and its length is the sum of the lengths of the individual line segments.

Input

The only line of the input contains two integers n and m (0 ≤ n, m ≤ 1000). It is guaranteed that grid contains at least 4 different points.

Output

Print 4 lines with two integers per line separated by space — coordinates of points p1, p2, p3, p4 in order which represent the longest possible polyline.

Judge program compares your answer and jury's answer with 10 - 6 precision.

Sample test(s)
input
1 1
output
1 1
0 0
1 0
0 1
input
0 10
output
0 1
0 10
0 0
0 9

------------------------------------------------------------------------------------------------------------------

说的是给你一个矩形区域,让你画三条线,怎样画使得线最长

根据n和m的大小,有四种画法,一是X型,一是斜对角的Z型

#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
int n,m;
scanf("%d%d",&n,&m);
if(n==)
{
printf("0 1\n0 %d\n0 0\n0 %d\n",m,m-);
}
else if(m==)
{
printf("1 0\n%d 0\n0 0\n%d 0\n",n,n-);
}
else if(m>=n)
{
if(*sqrt(m*m+n*n)+m<sqrt(m*m+n*n)+*sqrt(m*m+(n-)*(n-))) printf("1 0\n%d %d\n0 0\n%d %d\n",n,m,n-,m);
else printf("0 0\n%d %d\n%d 0\n0 %d\n",n,m,n,m);
}
else
{
if(*sqrt(m*m+n*n)+n<sqrt(m*m+n*n)+*sqrt((m-)*(m-)+n*n)) printf("0 1\n%d %d\n0 0\n%d %d\n",n,m,n,m-);
else printf("0 0\n%d %d\n0 %d\n%d 0\n",n,m,m,n);
}
return ;
}

MemSQL Start[c]UP 2.0 - Round 1(无聊练手B题)的更多相关文章

  1. MemSQL Start[c]UP 2.0 - Round 2 - Online Round

    搞到凌晨4点一个没出,要gg了. A. Golden System http://codeforces.com/contest/458/problem/A #include<cstdio> ...

  2. MemSQL Start[c]UP 2.0 - Round 1

    A. Eevee http://codeforces.com/contest/452/problem/A 字符串水题 #include<cstdio> #include<cstrin ...

  3. MemSQL Start[c]UP 2.0 - Round 2

    反正晚上睡不着,熬到1点开始做比赛,6个题目只做了2个题目,而且手速还比较慢,待提升空间还很大呢. A题:给定两个0,1串(len<=100000), 但是不是普通的二进制串,而是q进制串,q ...

  4. MemSQL Start[c]UP 2.0 - Round 1E. Three strings

    题意:给3个字符串,问从1到min(l1,l2,l3)的长度的子串,找到从该位置长度为l,三个子串相同的三元组的个数 题解:把3个子串用分隔符串起来.然后分开统计每个节点在三个串中出现次数.最后乘起来 ...

  5. Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) E

    题意:减前面的数,加后面的数,保证最后不剩下数,加减次数要相同: 题解:emmmmm,看出是个贪心,先对价值排序,相同就对下标排序,规律是每次找第一个,然后从后往前找没有使用过的下表比他大的第一个,相 ...

  6. 【MemSQL Start[c]UP 3.0 - Round 1 E】Desk Disorder

    [链接]h在这里写链接 [题意] 有N个人. 2N个座位. 现在告诉你这N个人它们现在的座位.以及它们想去的座位. 每个人可以去它们想去的座位或者就站在原地不动. 新的座位和旧的座位,都不允许一个座位 ...

  7. 【MemSQL Start[c]UP 3.0 - Round 1 C】 Pie Rules

    [链接]h在这里写链接 [题意] 在这里写题意 [题解]     dp[i][0] 第i个位置,bob没有决策权     dp[i][1] 第i个位置,bob有决策权     dp[n][0] = 0 ...

  8. 【MemSQL Start[c]UP 3.0 - Round 1 B】 Lazy Security Guard

    [链接]h在这里写链接 [题意] 围成对应面积的方块最少需要多少条边. [题解] 有特定的公式的. 2*ceil(2*根号下(n)); -> 自己找下规律也很简单的. [错的次数] 0 [反思] ...

  9. 【MemSQL Start[c]UP 3.0 - Round 1 A】 Declined Finalists

    [链接]h在这里写链接 [题意] 在这里写题意 [题解] max(最大值-25,0) [错的次数] 0 [反思] 在这了写反思 [代码] #include <bits/stdc++.h> ...

随机推荐

  1. Linux 封闭端口和安全

    两种方法: 1.停掉没用的服务,关闭端口监听 2.用 iptables 封闭端口 ######################################## 1.查看端口和占用服务 netsta ...

  2. 【python cookbook】【数据结构与算法】3.保存最后N个元素

    问题:希望在迭代或是其他形式的处理过程中对最后几项记录做一个有限的历史记录统计 解决方案:选择collections.deque. 如下的代码对一系列文本行做简单的文本匹配操作,当发现有匹配时就输出当 ...

  3. (转)java线程安全问题之静态变量、实例变量、局部变量

    java多线程编程中,存在很多线程安全问题,至于什么是线程安全呢,给出一个通俗易懂的概念还是蛮难的,如同<java并发编程实践>中所说: 写道 给线程安全下定义比较困难.存在很多种定义,如 ...

  4. [转]Win7下安装配置sharepoint server 2010

    转自:http://blog.sina.com.cn/s/blog_5d93d7aa010151lp.html 要开发SharePoint 2010应用程序,开发人员必须构建一个SharePoint ...

  5. [转]centos中wget的使用方法

    本文转自 http://www.cnblogs.com/chusiping/archive/2011/11/10/2243805.html 和 http://www.jb51.net/os/RedHa ...

  6. 如何在VS2013中新建WindowsService定时任务

    http://jingyan.baidu.com/article/cd4c2979e9330d756f6e6070.html 很多人都想做定时任务,但是没有不知道如何下手,现在就用WindowsSer ...

  7. 【PHP设计模式 08_CeLue.php】策略模式

    <?php /** * [策略模式]----和"简单工厂"模式很相似 * 根据不同运算符计算两个数的运算结果 * 常规方式就是判断运算符然后进行if...else的操作 * ...

  8. 微信支付 APP 支付方式的服务器端处理程序

    对于微信的APP的支付,客户服务说只能通过微信开放平台申请.后来在公众帐号确实发现了证据:  微信支付在申请的时候就比较严(麻烦),对服务类的一些支付,本来商品就是虚拟的,所以需要将商品描述的比较详细 ...

  9. 在ecshop顶部会员信息提示区显示会员等级

    会员登陆后,在顶部会员信息提示区显示会员等级会员登陆后会在顶部出现这样的提示:您好,test2, 欢迎您回来 ! 进入用户中心 |退出现在设想在会员名后面加上“会员等级”效果如下:您好,test2,  ...

  10. ACM题目————数素数

    令Pi表示第i个素数.现任给两个正整数M <= N <= 104,请输出PM到PN的所有素数. 输入格式: 输入在一行中给出M和N,其间以空格分隔. 输出格式: 输出从PM到PN的所有素数 ...