Codeforces Round #237 (Div. 2) B. Marathon(卡long long)

题目:http://codeforces.com/contest/404/problem/B

 #include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std; int main()
{
__int64 g; //g一定要是长整形,因为数据会超int.这个也是错误的最主要原因
int n, i;
double a, d, x, y, sum, cnt;
while(~scanf("%lf%lf%d", &a, &d, &n))
{
sum = (double)(a*);
for(i = ; i <= n; i++)
{
cnt = (double)i*d; g =(long long)(cnt/sum); //这里一定把要转换的部分加上括号
cnt = (double)(cnt-g*sum);
if(cnt-a<=)
{
y = ;
x = cnt;
}
else if(cnt-*a<=)
{
x = a;
y = cnt-a;
}
else if(cnt-*a<=)
{
x = a-(cnt-*a);
y = a;
}
else
{
x = ;
y = a-(cnt-*a);
}
printf("%.10lf %.10lf\n", x, y);
}
}
return ;
}
上一篇:c++ 数据持久层研究(一)


下一篇:CSS实现文字省略