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

题意:一个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. bzoj 4481 [ Jsoi 2015 ] 非诚勿扰 —— 期望

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4481 太弱了这种题都要看半天TJ...:https://blog.csdn.net/chai ...

  2. Webpack 2.0 的文档

    Webpack 2.0 的文档 https://webpack.js.org/get-started/

  3. [Luogu2324]八数码难题

    抱歉...我可能真的做搜索上瘾了... 还是IDA*,自己看看就好了... 注意一下搜索顺序 #include<cstdio> #include<queue> #include ...

  4. XOJ测试 2016.5.22

    哈哈 我是最先使用XOJ的人之一 膜拜zrt ing 首先是XOJ神奇的界面 还没有建设完的OJ是这个样子的 一共有5道题 这次小测有3道题 是T2T3T4 首先是骑士精神 (BZOJ1085) 上来 ...

  5. A - HQ9+

    Problem description HQ9+ is a joke programming language which has only four one-character instructio ...

  6. bootstrap 网格布局

    一:基本的网格布局 <div class="container"> <div class="row"> <div class=&q ...

  7. 前端Canvas思维导图笔记

    看不清的朋友右键保存或者新窗口打开哦!喜欢我可以关注我,还有更多前端思维导图笔记

  8. 去除DialogFragment的背景阴影,背景色,标题栏

    style中: <resources xmlns:android="http://schemas.android.com/apk/res/android"> <s ...

  9. mysqlslap对mysql进行压力测试

    mysqlslap是从5.1.4版开始的一个MySQL官方提供的压力测试工具.通过模拟多个并发客户端访问MySQL来执行压力测试,并且能很好的对比多个存储引擎在相同环境下的并发压力性能差别. mysq ...

  10. mssql for VSCode Guide

    前言 mssql 出自微软自己的 Visual Studio Code 开源插件,代码托管于 GitHub 上. 不过需要注意的一点是,使用 insert into 语句新增的数据...中文是会乱码的 ...