链接:http://codeforces.com/contest/404/problem/B

B. Marathon
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.

Output

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.

Sample test(s)
input
2 5
2
output
1.0000000000 2.0000000000
2.0000000000 0.0000000000
input
4.147 2.8819
6
output
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题模拟题的更多相关文章

  1. Codeforces Round #524 (Div. 2)(前三题题解)

    这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:h ...

  2. Codeforces Round #190 (Div. 2) 水果俩水题

    后天考试,今天做题,我真佩服自己... 这次又只A俩水题... orz各路神犇... 话说这次模拟题挺多... 半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来... A: 算是模拟 ...

  3. Codeforces Round #426 (Div. 2)A B C题+赛后小结

    最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. Codeforces Round #543 (Div. 2) D 双指针 + 模拟

    https://codeforces.com/contest/1121/problem/D 题意 给你一个m(<=5e5)个数的序列,选择删除某些数,使得剩下的数按每组k个数以此分成n组(n*k ...

  9. Codeforces Round #398 (Div. 2) A. Snacktower 模拟

    A. Snacktower 题目连接: http://codeforces.com/contest/767/problem/A Description According to an old lege ...

随机推荐

  1. delphi 与 C++的基本语法区别

    [1]“=”符号 (1)“=”作为比较符.但是,当定义const常量时,“=”又表示赋值符号.而“:=”作为赋值符号. (2)“=”只表示赋值符号 [2]结构体 (1)record 作为结构体 (2) ...

  2. android 弹幕效果demo

    记得之前有位朋友在我的公众号里问过我,像直播的那种弹幕功能该如何实现?如今直播行业确实是非常火爆啊,大大小小的公司都要涉足一下直播的领域,用斗鱼的话来讲,现在就是千播之战.而弹幕则无疑是直播功能当中最 ...

  3. mysql主从同步及清除信息

    主:reset master; 从:reset slave all; mysql主从配置: 1.MySQL主配置文件增加如下:default-storage-engine = innodbinnodb ...

  4. Google 开发新的开源系统 Fuchsia

    google 最新os 下载 https://github.com/fuchsia-mirror/magenta 本文转自:http://www.oschina.net/news/76094/goog ...

  5. Android常见面试题目

    1.Activity 的生命周期 转自:http://kb.cnblogs.com/page/70125/ 多谢楼主分享 首先看一下Android api中所提供的Activity生命周期图(不明白的 ...

  6. Oracle:Authid Current_User使用

    由于用户拥有的role权限在存储过程是不可用的.遇到这种情况,我们一般需要显示授权,如grant create table to user;但这种方法太麻烦,有时候可能需要进行非常多的授权才能执行存储 ...

  7. json-encode()怎么进行解码呢?

    解决中文的一种方法就是先将中文转换为另一种编码格式,然后再使用json_encode(),最后再用解码把json串进行解码.还有一种方式就在php新版本中得到了解决,在下面的代码为展示. 以下为代码示 ...

  8. PHP的数据类型、常量、时间

    [数据类型之间相互转换] ◆ 一种是强制转换: setType( 变量, 类型);  // 类型 int, integer, float, double,real, bool, boolena, st ...

  9. 【转】MYSQL入门学习之六:MYSQL的运算符

    转载地址:http://www.2cto.com/database/201212/175862.html 一.算术运算符 1.加  www.2cto.com           mysql> s ...

  10. 使用 Filter 完成一个简单的权限模型

    ****对访问进行权限控制: 有权限则可以访问, 否则提示: 没有对应的权限, 请 返回其访问者的权限可以在manager那进行设置: