MemSQL Start[c]UP 2.0 - Round 1(无聊练手B题)
2 seconds
256 megabytes
standard input
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.
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.
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.
1 1
1 1
0 0
1 0
0 1
0 10
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题)的更多相关文章
- MemSQL Start[c]UP 2.0 - Round 2 - Online Round
搞到凌晨4点一个没出,要gg了. A. Golden System http://codeforces.com/contest/458/problem/A #include<cstdio> ...
- MemSQL Start[c]UP 2.0 - Round 1
A. Eevee http://codeforces.com/contest/452/problem/A 字符串水题 #include<cstdio> #include<cstrin ...
- MemSQL Start[c]UP 2.0 - Round 2
反正晚上睡不着,熬到1点开始做比赛,6个题目只做了2个题目,而且手速还比较慢,待提升空间还很大呢. A题:给定两个0,1串(len<=100000), 但是不是普通的二进制串,而是q进制串,q ...
- MemSQL Start[c]UP 2.0 - Round 1E. Three strings
题意:给3个字符串,问从1到min(l1,l2,l3)的长度的子串,找到从该位置长度为l,三个子串相同的三元组的个数 题解:把3个子串用分隔符串起来.然后分开统计每个节点在三个串中出现次数.最后乘起来 ...
- Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) E
题意:减前面的数,加后面的数,保证最后不剩下数,加减次数要相同: 题解:emmmmm,看出是个贪心,先对价值排序,相同就对下标排序,规律是每次找第一个,然后从后往前找没有使用过的下表比他大的第一个,相 ...
- 【MemSQL Start[c]UP 3.0 - Round 1 E】Desk Disorder
[链接]h在这里写链接 [题意] 有N个人. 2N个座位. 现在告诉你这N个人它们现在的座位.以及它们想去的座位. 每个人可以去它们想去的座位或者就站在原地不动. 新的座位和旧的座位,都不允许一个座位 ...
- 【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 ...
- 【MemSQL Start[c]UP 3.0 - Round 1 B】 Lazy Security Guard
[链接]h在这里写链接 [题意] 围成对应面积的方块最少需要多少条边. [题解] 有特定的公式的. 2*ceil(2*根号下(n)); -> 自己找下规律也很简单的. [错的次数] 0 [反思] ...
- 【MemSQL Start[c]UP 3.0 - Round 1 A】 Declined Finalists
[链接]h在这里写链接 [题意] 在这里写题意 [题解] max(最大值-25,0) [错的次数] 0 [反思] 在这了写反思 [代码] #include <bits/stdc++.h> ...
随机推荐
- 广播发送者&广播接收者介绍
1.广播接收者 广播接收者简单地说就是接收广播意图的Java类,此Java类继承BroadcastReceiver类,重写: public void onReceive(Context context ...
- Thinkphp用exp表达式执行mysql语句,查询某字段不为空is not null,自动增值
Thinkphp用exp表达式执行mysql语句,查询某字段不为空is not null,自动增值 Thinkphp 的文档经常不够完整的表达MYSQL的各种组合,is not null在thinkp ...
- TI CC2541的串口输出.
http://blog.csdn.net/feilusia/article/details/47431659 基本上看上面这个博客的. 重点是: 1. 关闭流控, 在npi.h里面, 将 #defin ...
- composer未升级报错
错误: Cannot adopt OID in SQUID-MIB: cacheClients ::= { cacheProtoAggregateStats 15 } Cannot adopt OID ...
- CentOS6.5系统软件仓库及挂载NTFS
第一步:下载rpmforge,下载对应的版本,就是对应CentOS版本,还有32位与64位也要对应上.rpmforge拥有4000多种CentOS的软件包,被CentOS社区认为是最安全也是最稳定的一 ...
- flex 调用gp服务
同步异步说明: gp服务分为同步和异步两种模式,两者的区别是:同步:适合于快速的处理,数据量较小,本质区别在于同步模式,服务器处理之后,处理结果并不在服务器端保存,而是将结果发送至客户端,由客户端去显 ...
- STM32F0系列MCU中断向量表的重映射
最近使用了一款Cortex-M0内核的芯片STM32F030CC,发现它中断向量表的重映射方法与STM32F10x系列的有所区别,在这里记录与分享一下. 由于需要通过IAP进行固件升级,所以芯片的FL ...
- 严重: IOException while loading persisted sessions: java.io.EOFException
tomcat在启动时出现如下异常问题: 严重: IOException while loading persisted sessions: java.io.EOFException 严重: Excep ...
- golang的helloworld
新建源码文件hello.go mkdir -p /work/goTest/ cd /work/goTest/ vim hello.go 编码hello.go文件: package main impor ...
- northwind数据库介绍
① Categories: 种类表相应字段:CategoryID :类型ID:CategoryName:类型名;Description:类型说明;Picture:产品样本 ② CustomerCust ...