Codeforces 404 B Marathon "fmod to floating point"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.