Test instructions: Give a square with an edge length of a, give D, give n, output the coordinates of the distance i D
This article of study
http://blog.csdn.net/synapse7/article/details/21595639
Fmod can be used to take the floating-point number of surplus
Then when D is very big time, does the division easy to produce the big error, therefore first uses fmod (D,4*A) to deal with (turns out does not handle, will WA in 11 data)
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <stack>6#include <vector>7#include <map>8#include <Set>9#include <queue>Ten#include <algorithm> One using namespacestd; A - #defineforeach (I,c) for (__typeof (C.begin ()) i = C.begin (); I! = C.end (); ++i) - thetypedefLong LongLL; - Const intINF = (1<< -)-1; - Const intMod=1000000007; - Const intmaxn=100005; + - Doublea,d; + intN; A at voidFDoubleLen) { - intAns= (int) (len/a)%4; -len=Fmod (len,a); - if(ans==0) printf ("%f 0\n", Len); - if(ans==1) printf ("%f%f\n", A,len); - if(ans==2) printf ("%f%f\n", A-len,a); in if(ans==3) printf ("0%f\n", A-len); - } to + - intMain () { theCin>>a>>d>>N; *D = Fmod (d,4*a); $ for(intI=1; i<=n;i++) F (i*d);Panax Notoginseng}
View Code
Codeforces 404 B Marathon "fmod to floating point"