Codeforces Round #237 (Div. 2) B题模拟题
链接:http://codeforces.com/contest/404/problem/B
1 second
256 megabytes
standard input
standard output
Valera takes part in the Berland Marathon. The marathon race starts at the stadium that can be represented on the plane as a square whose lower left corner is located at point with coordinates (0, 0) and the length of the side equals a meters. The sides of the square are parallel to coordinate axes.
As the length of the marathon race is very long, Valera needs to have extra drink during the race. The coach gives Valera a bottle of drink each d meters of the path. We know that Valera starts at the point with coordinates (0, 0) and runs counter-clockwise. That is, when Valera covers a meters, he reaches the point with coordinates (a, 0). We also know that the length of the marathon race equalsnd + 0.5 meters.
Help Valera's coach determine where he should be located to help Valera. Specifically, determine the coordinates of Valera's positions when he covers d, 2·d, ..., n·d meters.
The first line contains two space-separated real numbers a and d (1 ≤ a, d ≤ 105), given with precision till 4 decimal digits after the decimal point. Number a denotes the length of the square's side that describes the stadium. Number d shows that after each dmeters Valera gets an extra drink.
The second line contains integer n (1 ≤ n ≤ 105) showing that Valera needs an extra drink n times.
Print n lines, each line should contain two real numbers xi and yi, separated by a space. Numbers xi and yi in the i-th line mean that Valera is at point with coordinates (xi, yi) after he covers i·d meters. Your solution will be considered correct if the absolute or relative error doesn't exceed 10 - 4.
Note, that this problem have huge amount of output data. Please, do not use cout stream for output in this problem.
2 5
2
1.0000000000 2.0000000000
2.0000000000 0.0000000000
4.147 2.8819
6
2.8819000000 0.0000000000
4.1470000000 1.6168000000
3.7953000000 4.1470000000
0.9134000000 4.1470000000
0.0000000000 2.1785000000
0.7034000000 0.0000000000 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
记录下,没事的时候拿来看看!!!
#include <cstdio>
#include <cmath> using namespace std; double a, d, n; void init() { scanf("%lf%lf%lf", &a, &d, &n);
} void solve() { double sum = ; for (int i = ; i <= n; i++) { sum += d; long long m = floor(sum/a);
double r = sum-m*a;
m %= ; long long tmp = floor(sum/(*a));
sum -= tmp**a; switch (m) { case : printf("%.10lf %.10lf\n", r, 0.0);
break;
case : printf("%.10lf %.10lf\n", a, r);
break;
case : printf("%.10lf %.10lf\n", a-r, a);
break;
case : printf("%.10lf %.10lf\n", 0.0, a-r);
break;
}
}
} int main()
{ init();
solve();
}
Codeforces Round #237 (Div. 2) B题模拟题的更多相关文章
- Codeforces Round #524 (Div. 2)(前三题题解)
这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:h ...
- Codeforces Round #190 (Div. 2) 水果俩水题
后天考试,今天做题,我真佩服自己... 这次又只A俩水题... orz各路神犇... 话说这次模拟题挺多... 半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来... A: 算是模拟 ...
- Codeforces Round #426 (Div. 2)A B C题+赛后小结
最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...
- Codeforces Round #237 (Div. 2) A
链接:http://codeforces.com/contest/404/problem/A A. Valera and X time limit per test 1 second memory l ...
- Codeforces Round #185 (Div. 2) B. Archer 水题
B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...
- Codeforces Round #301 (Div. 2)(A,【模拟】B,【贪心构造】C,【DFS】)
A. Combination Lock time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...
- Codeforces Round #345 (Div. 2)【A.模拟,B,暴力,C,STL,容斥原理】
A. Joysticks time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...
- Codeforces Round #543 (Div. 2) D 双指针 + 模拟
https://codeforces.com/contest/1121/problem/D 题意 给你一个m(<=5e5)个数的序列,选择删除某些数,使得剩下的数按每组k个数以此分成n组(n*k ...
- Codeforces Round #398 (Div. 2) A. Snacktower 模拟
A. Snacktower 题目连接: http://codeforces.com/contest/767/problem/A Description According to an old lege ...
随机推荐
- notification 通知
1. 定义一个方法 -(void) update{ } 2. 对象注册,并关连消息 [[NSNotificationCenter defaultCenter]addObserver:self sele ...
- FastJson--阿里巴巴公司开源的速度最快的Json和对象转换工具(转)
本文转自:http://blog.csdn.net/djun100/article/details/24237371 这是关于FastJson的一个使用Demo,在Java环境下验证的 class U ...
- 160922、配置:spring通过profile或@profile配置不同的环境(测试、开发、生产)
一.配置环境 applicationContext.xml中添加下边的内容(develop:开发环境,production:生产环境,test:测试环境) 注意:profile的定义一定要在文档的最下 ...
- semantic-ui and IE only message
<![if !IE]> <div class="ui message red"> <i class="close icon"> ...
- linux的lsof命令
删除文件,用命令df -h看磁盘空间,但发现没有变化. 这种情况,需要使用命令查看是不是文件被某个进程占用了: /usr/sbin/lsof |grep deleted
- iOS学习之Table View的简单使用
Table View简单描述: 在iPhone和其他iOS的很多程序中都会看到Table View的出现,除了一般的表格资料展示之外,设置的属性资料往往也用到Table View,Table View ...
- linux 时钟源初步分析linux kernel 时钟框架详细介绍
初步概念: 看datasheet的关于时钟与定时器的部分, FCLK供给cpu, HCLK供给AHB总线设备(存储器控制器,中断控制器.LCD控制器.DMA.USB主机控制器等), PCLK供给APB ...
- 网站性能优化之CSS无图片技术:三角形
1.使用CSS无图片技术,可以总结得到以下三个优点: 减少请求资源的大小: 减少http的请求个数: 提高可维护性. 一.CSS无图片技术,微博中有哪些实际应用呢? 通过上面的展示,我们可以看到,无图 ...
- ubuntu配置服务器环境
今天环境不知道怎么就不能用了.自己新配了一个: 添加源: vi /etc/apt/sources.list 将下面这些源添加进去: deb http://debian.ustc.edu.cn/ubun ...
- Android的BroadcastReceiver 广播 短信拦截
如何去理解BroadcastReceiver(广播)?其实可以这样想,首先我们要有一个发送广播的"媒体",在这个例子中,我们暂且用activity组件作为这个媒体,当然以后会用到s ...