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

题意:一个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. 协同过滤算法中皮尔逊相关系数的计算 C++

    template <class T1, class T2>double Pearson(std::vector<T1> &inst1, std::vector<T ...

  2. TCP打开文件传输(服务器端并发code)

    #include <stdio.h>#include <stdlib.h>#include <arpa/inet.h>#include <sys/types. ...

  3. 74.资金管理-员工工资配置 extjs 页面

    1. <%@ page language="java" import="java.util.*" pageEncoding="UTF-8&quo ...

  4. 新建项目git clone

  5. Oracle_备份整库

    @echo off color 0b & cls echo echo 设置备份文件存放文件夹... echo set "tbuf=C:\OracleBackup" if n ...

  6. [转]RDLC 动态列

    本文转自:http://blog.csdn.net/luochengbang/article/details/9964551 很久没有写博客了,关于动态列,国内很少资料有介绍动态列的,所想写点心得给哥 ...

  7. Y - Anton and Letters

    Problem description Recently, Anton has found a set. The set consists of small English letters. Anto ...

  8. CentOS6 在线安装PostgreSQL10

    本文主要通过实际案例介绍如何在CentOS6环境中在线安装PostgreSQL10,安装环境需具备能够使用yum在线安装功能.具体安装步骤如下, 1 下载对应版本的PGDG文件 从https://yu ...

  9. JavaScript(基于react+dva)

    变量声明 const 和 let:分别表示常量和变量 模板字符串 const user = 'world'; console.log(`hello ${user}`); // hello world ...

  10. iconfont在ios(safari)中的坑

    最近公司决定将项目图标整体迁移到iconfont,按网上常规方法,在安卓.pc端都没问题,唯独在ios的safari浏览器及微信内置浏览器中,iconfont始终在正常位置向下偏移,导致图标错乱. 网 ...