水题,就是把一个矩形平分。

题意:一个wid*hei的矩形,过底边上的一点(dor,0)做m-1条射线,把这个矩形的面积平均分成m份,求这些射线和矩形的另外一个交点。

直接枚举,然而求三角形高底移动坐标即可。

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath> using namespace std;
struct pointer {
double x,y;
}ans[120];
const double eps=0.00000001; int main(){
int wid,heg,door,p;
while(scanf("%d%d%d%d",&wid,&heg,&door,&p)!=EOF){
if(wid==0&&heg==0&&door==0&&p==0) break;
double ye=0,xe=wid,ys=heg;
double parea=(wid*heg)*1.0/p;
double part1=(wid-door)*heg*1.0/2;
double part2=wid*heg*1.0/2;
double part3=(door)*heg*1.0/2;
double tmp;
for(int i=0;i<p;i++){
tmp=parea;
if(part1>eps){
if(tmp-eps>part1){
tmp-=part1;
part1=0;
}
else if(fabs(tmp-part1)<=eps){
ans[i].x=wid; ans[i].y=heg;
part1=0;
continue;
}
else {
double yy=(tmp*2)/(wid-door);
ye+=yy;
ans[i].x=wid; ans[i].y=ye;
part1-=tmp;
continue;
}
}
if(part2>eps){
if(tmp-eps>part2){
tmp-=part2;
part2=0;
}
else if(fabs(tmp-part2)<=eps){
ans[i].x=0; ans[i].y=heg;
part2=0;
continue;
}
else {
double xx=(tmp*2)/heg;
xe-=xx;
ans[i].x=xe; ans[i].y=heg;
part2-=tmp;
continue;
}
}
if(part3>eps){
if(tmp-eps>part3){
tmp-=part3;
part2=0;
}
else if(fabs(tmp-part3)<=eps){
ans[i].x=0; ans[i].y=0;
part3-=0;
continue;
}
else{
double yy=(tmp*2)/door;
ys-=yy;
ans[i].x=0; ans[i].y=ys;
part2-=tmp;
continue;
}
}
}
printf("%.3lf %.3lf",ans[0].x,ans[0].y);
for(int i=1;i<p-1;i++){
printf(" %.3lf %.3lf",ans[i].x,ans[i].y);
}
printf("\n");
}
return 0;
}

  

HDU 3432的更多相关文章

  1. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  2. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  3. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  4. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  5. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  6. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  7. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  8. hdu 4481 Time travel(高斯求期望)(转)

    (转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...

  9. HDU 3791二叉搜索树解题(解题报告)

    1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...

随机推荐

  1. VS2010中文注释带红色下划线的解决方法

    环境:Visual Studio 2010 问题:代码中出现中文后会带下划线,很多时候感觉很不舒服.找了很久的原因没找到,后来无意中在VisualAssist X里找到了解决办法. 1.安装完Visu ...

  2. Java并发基础知识点详解

    1.synchronized与Lock区别 父类有synchtonized,子类调用父类的同步方法,是没办法同步的,因为synchronized不是修饰符,不会被继承下来. synchronized ...

  3. DotnetCore安装介绍

    微软的DotnetCore发布至今,已经有段时间了,我们都非常关注我们它能为我们带来什么,我们能通过它做什么?要解决这些问题,不仅仅需要基本的了解意外,还需要知道是开发环境是怎么搭建的,接下来我们就一 ...

  4. 后端springmvc,前端html5的FormData实现文件断点上传

    前言 最近项目中有使用到文件断点上传,得空便总结总结,顺便记录一下,毕竟“好记性不如烂笔头”. 后端代码: package com.test.controller; import java.io.Bu ...

  5. 【Oracle】解决oracle sqlplus 中上下左右backspace不能用

    一. 解决输入 BACKSPACE 键变成 ^h 的问题 #su - oracle   $stty erase ^h. 要永久生效,可以加入到用户环境配置文件.bash_profile中(vi .ba ...

  6. CDC之Synchronizers

    1 Scenarios Two scenarios for passing signals across CDC boundaries: 1) sometimes it's not necessary ...

  7. 【JSP】中文乱码问题

     原作者http://www.cnblogs.com/xing901022/p/4354529.html 阅读目录 之前总是碰到JSP页面乱码的问题,每次都是现在网上搜,然后胡乱改,改完也不明白原因. ...

  8. [Intermediate Algorithm] - Binary Agents

    题目 传入二进制字符串,翻译成英语句子并返回. 二进制字符串是以空格分隔的. 提示 String.charCodeAt() String.fromCharCode() 测试用例 binaryAgent ...

  9. (转)Arcgis for Js之GeometryService实现测量距离和面积

    http://blog.csdn.net/gisshixisheng/article/details/40540601 距离和面积的测量时GIS常见的功能,在本节,讲述的是通过GeometryServ ...

  10. HDU_2149_基础博弈sg函数

    Public Sale Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...