# Bzoj 1041 haoi2008 round vertices Number Theory

Source: Internet
Author: User

x^2+y^2=r^2

y=d*u*v

r=d*(u^2+v^2)/2

`#include<cmath>#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;typedef long long ll;ll r,ans;ll factors[100100];int tot;void Get_Factors(ll x){ll i;for(i=1;i*i<x;i++)if(x%i==0)factors[++tot]=i,factors[++tot]=x/i;if(i*i==x)factors[++tot]=i;}ll GCD(ll x,ll y){return y?GCD(y,x%y):x;}bool Is_Square(ll x){double temp=sqrt( (double)x );if(fabs(floor(temp+1e-7)-temp)<1e-7)return true;return false;}int main(){cin>>r;int i;ll u;Get_Factors(r<<1);for(i=1;i<=tot;i++){ll d=factors[i];for(u=1;u*u<(r+1)/d;u++){ll v_2=r*2/factors[i]-u*u;if( Is_Square(v_2) )if(GCD(v_2,u*u)==1)++ans;}}cout<<(ans+1<<2)<<endl;}`

BZOJ 1041 HAOI2008 圆上的整点 数论

Related Keywords:

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.