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. xhr dojo load

    require(["dojo/_base/xhr"], function(xhr) { // Execute a HTTP GET request xhr.get({ // The ...

  2. Linux Runtime PM介绍【转】

    转自:http://blog.csdn.net/wlwl0071986/article/details/42677403 一.Runtime PM引言 1. 背景 (1)display的需求 (2)系 ...

  3. oracle 数据泵 每天自动备份

    @echo off echo 删除10天前的备分文件和日志 forfiles /p "e:\app\back" /m *.dmp /d -5 /c "cmd /c del ...

  4. phpize 动态添加 PHP 扩展的错误及解决方案

    使用phpize 动态添加 PHP 扩展是开发中经常需要做的事情,但是在 macOS 中,首次使用该功能必然会碰到一些错误,本文列出了这些错误的解决方法. 问题一: 执行 phpize 报错如下: $ ...

  5. 9、Http回顾/Servlet

    1 Http回顾 Http协议: 1)http协议: 对浏览器客户端和服务器端之间数据传输的格式规范. 2)http请求:浏览器->服务器端 格式: 请求行(请求方式(GET/POST) 请求资 ...

  6. mongodb 2.6 window 安装启动服务

    安装目录:C:\Program Files\MongoDB 2.6 Standard\ 创建目录:D:\mongodb\data   通过cmd,执行如下命令: cd C:\Program Files ...

  7. java事务的类型——面试被问到

    Java事务的类型有三种:JDBC事务.JTA(Java Transaction API)事务.容器事务. 1.JDBC事务 JDBC 事务是用 Connection 对象控制的.JDBC Conne ...

  8. Channel Allocation

    Channel Allocation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13231 Accepted: 6774 D ...

  9. Linux vim的安装和配置:

    1:首先就碰到一个问题 程序 'vim' 已包含在下列软件包中: * vim * vim-gnome * vim-tiny * vim-athena * vim-gtk * vim-nox 请尝试:s ...

  10. java web简单权限管理设计

    一套最基本的权限管理包括用户.角色.资源. 数据库设计 我的设计如下: 用户:user 角色:role 用户-角色:user_role 资源:resource(包括上级菜单.子菜单.按钮等资源) 角色 ...