HDU 4279 number Pit father's mystery of precision

Source: Internet
Author: User

Title Description
首先定义"special number":    如果对于一个数字B,存在一个数字A(0<A<=B),并同时满足 B%A=0 和 gcd(A,B) != 1 ,那么我们就说A是B的"special number"。    再定义一个函数f(x)表示x的"special number"的数量。并且如果f(x)%2=1时,我们就称x为"real number"。    现在给你两个数字x和y且1<=x<=y<=2^63-1,求再[x,y]区间内"real number"的数量。

Analysis:

看到范围后,这题第一眼就打表有木有,然后自己拿着数据去YY.......,然后就搞定。然而就是挂掉了。最后发现竟然在开方这里。赛后试了下,如果这样: ans = sqrt(n) 就过不了如果改成:ans = sqrt((long double)n) 就过了然后本人手贱又尝试了一下这个:ans = sqrt((double)n) 还是过不了难道long double 和 double 不是一个东西 ?unsigned long long  开方竟然会有精度损失 ?迷也......

The code is as follows:

@Frosero#include <iostream>#include <cstdio>#include <cmath>#define INF 0x3f3f3f3fusing namespace STD;intTunsigned Long LongP,a,b,x,y;unsigned Long LongHow (unsigned Long LongN) {unsigned Long Longans,tmp;if(N <6)return 0; Ans = n/2-2; TMP =sqrt((Long Double) n);if(TMP &1) ans++;returnAns;}intMain () {scanf("%d", &t); while(t--) {Cin>>a>>b;  y = how (b); x = How (A-1);cout<<y-x<<endl; }return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HDU 4279 number Pit father's mystery of precision

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.