1041: [HAOI2008]圆上的整点

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://www.lydsy.com/JudgeOnline/problem.php?id=1041

Description

求一个给定的圆(x^2+y^2=r^2),在圆周上有多少个点的坐标是整数。

Input

r

Output

整点个数

Sample Input

4

Sample Output

4

HINT

n<=2000 000 000

题意

题解:

http://hzwer.com/1457.html

代码:

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 2000001
#define mod 10007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//**************************************************************************************
ll r,ans;
ll gcd(ll a,ll b)
{
return b==?a:gcd(b,a%b);
}
int check(ll y,double x)
{
if(x==floor(x))
{
ll x1=(ll)floor(x);
if(gcd(x1*x1,y*y)==&&x1*x1!=y*y)
return ;
}
return ;
} int main()
{
r=read();
for(ll i=;i<=sqrt(*r);i++)
{
if((*r)%i==)
{
for(ll a=;a<=sqrt(r/i);a++)
{
double b=sqrt(((*r)/i)-a*a);
if(check(a,b))
ans++;
}
if(i!=(*r)/i)
{
for(ll a=;a<=sqrt(i/);a++)
{
double b=sqrt(i-a*a);
if(check(a,b))
ans++;
} }
}
}
cout<<ans*+<<endl;
}

bzoj 1041: [HAOI2008]圆上的整点 数学的更多相关文章

  1. BZOJ 1041: [HAOI2008]圆上的整点【数论,解方程】

    1041: [HAOI2008]圆上的整点 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 4210  Solved: 1908[Submit][Sta ...

  2. BZOJ 1041: [HAOI2008]圆上的整点

    1041: [HAOI2008]圆上的整点 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 3621  Solved: 1605[Submit][Sta ...

  3. bzoj 1041: [HAOI2008]圆上的整点 本原勾股數組

    1041: [HAOI2008]圆上的整点 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 2027  Solved: 853[Submit][Stat ...

  4. BZOJ 1041 [HAOI2008]圆上的整点:数学

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1041 题意: 给定n(n <= 2*10^9),问你在圆x^2 + y^2 = n^ ...

  5. BZOJ 1041 [HAOI2008]圆上的整点:数学【费马平方和定理】

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1041 题意: 给定n(n <= 2*10^9),问你在圆x^2 + y^2 = n^ ...

  6. BZOJ(2) 1041: [HAOI2008]圆上的整点

    1041: [HAOI2008]圆上的整点 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 4966  Solved: 2258[Submit][Sta ...

  7. 1041: [HAOI2008]圆上的整点

    1041: [HAOI2008]圆上的整点 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 4298  Solved: 1944[Submit][Sta ...

  8. 【BZOJ】1041: [HAOI2008]圆上的整点(几何)

    http://www.lydsy.com:808/JudgeOnline/problem.php?id=1041 所谓的神题,我不会,直接题解..看了半天看懂题解了.详见hzwer博客 这题呢,我只能 ...

  9. 1041: [HAOI2008]圆上的整点 - BZOJ

    Description 求一个给定的圆(x^2+y^2=r^2),在圆周上有多少个点的坐标是整数.Input rOutput 整点个数Sample Input4Sample Output4HINT n ...

随机推荐

  1. X86调用约定

    cdecl      C语言默认的调用约定,从右往左压栈,由调用者负责清栈,所以参数个数可以不固定: stdcall    windows默认调用方式,从右往左压栈,由被调用者负责栈操作. pasca ...

  2. redhat 下Redis安装

    Redis 官网:http://redis.io/  下载地址: http://redis.io/download 安装方法:   cd opt wget http://download.redis. ...

  3. Getting and installing the PEAR package manager

    Windows After you have downloaded and installed PHP, you have to manually execute the batch file loc ...

  4. bjfu1287字符串输出的大水题

    不多说 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> # ...

  5. javascript针对DOM的应用

    所谓针对DOM的应用.也就我这里只教大家用javascript操作页面中dom元素做交互.我相信可能大部分人来这里学javascript主要还是想用这个结合页面中的DOM元素做一些实际有用的交互效果. ...

  6. arp spoofing

    Today our tutorial will talk about Kali Linux Man in the Middle Attack. How to perform man in the mi ...

  7. Python:映像、集合

    一.字典 字典(dictionary)是Python中唯一的“映射”类型,映射这个概念在高中就学过:一个函数f将键(key, 定义域)映射到值(value, 值域).这样的函数在字典中可以称为哈希(H ...

  8. java&c# dec 加密,通用

    java /** * 解密DES * @param key 密钥,长度必须是8的倍数 * @param data 数据源 * @return 解密内容 */ public final static S ...

  9. html5 拖拽

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  10. localStorage的一些简单的操作

    本地存储     cookie     localStorage                           cookie             localStorage     生存周期 ...