R(N)

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2761    Accepted Submission(s):
1420

Problem Description
We know that some positive integer x can be expressed
as x=A^2+B^2(A,B are integers). Take x=10 for example,
10=(-3)^2+1^2.
We
define R(N) (N is positive) to be the total number of variable presentation of
N. So R(1)=4, which consists of 1=1^2+0^2, 1=(-1)^2+0^2, 1=0^2+1^2,
1=0^2+(-1)^2.Given N, you are to calculate R(N).
 
Input
No more than 100 test cases. Each case contains only
one integer N(N<=10^9).
 
Output
For each N, print R(N) in one line.
 
Sample Input
2
6
10
25
65
 
Sample Output
4
0
8
12
16

Hint

For the fourth test case, (A,B) can be (0,5), (0,-5), (5,0), (-5,0), (3,4), (3,-4), (-3,4), (-3,-4), (4,3) , (4,-3), (-4,3), (-4,-3)

 
Source
 
Recommend
xubiao
暴力题,注意不要超时就行了,注意sqrt的数一定得是int类型的。
include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
if(n==)
{
cout<<<<endl;
continue;
}
int c=sqrt(n/);
int ans=;
int i,j;
for(i=;i<=c;i++)
{
j=sqrt(n-i*i);
if(i*i+j*j==n)
{
if(i==||j==||i==j)
ans=ans+;
else
ans=ans+;
}
}
printf("%d\n",ans);
}
return ;
}

HDU 3835 R(N)的更多相关文章

  1. HDU 3835 R(N)(枚举)

    题目链接 Problem Description We know that some positive integer x can be expressed as x=A^2+B^2(A,B are ...

  2. hdu 3835:R(N)(水题,数学题)

    R(N) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  3. H - R(N)

    H - R(N) Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Sta ...

  4. [原]CentOS7安装Rancher2.1并部署kubernetes (二)---部署kubernetes

    ##################    Rancher v2.1.7  +    Kubernetes 1.13.4  ################ ##################### ...

  5. 利用python进行数据分析2_数据采集与操作

    txt_filename = './files/python_baidu.txt' # 打开文件 file_obj = open(txt_filename, 'r', encoding='utf-8' ...

  6. Django项目:CRM(客户关系管理系统)--81--71PerfectCRM实现CRM项目首页

    {#portal.html#} {## ————————46PerfectCRM实现登陆后页面才能访问————————#} {#{% extends 'king_admin/table_index.h ...

  7. POJ 3835 &amp; HDU 3268 Columbus’s bargain(最短路 Spfa)

    题目链接: POJ:http://poj.org/problem?id=3835 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=3268 Problem ...

  8. hdu 4630 查询[L,R]区间内任意两个数的最大公约数

    No Pain No Game Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  9. HDU 2031 进制转换(10进制转R进制)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2031 进制转换 Time Limit: 2000/1000 MS (Java/Others)    M ...

随机推荐

  1. poj 2142 扩展欧几里得解ax+by=c

    原题实际上就是求方程a*x+b*y=d的一个特解,要求这个特解满足|x|+|y|最小 套模式+一点YY就行了 总结一下这类问题的解法: 对于方程ax+by=c 设tm=gcd(a,b) 先用扩展欧几里 ...

  2. [NOIP2008] 提高组 洛谷P1006 传纸条

    题目描述 小渊和小轩是好朋友也是同班同学,他们在一起总有谈不完的话题.一次素质拓展活动中,班上同学安排做成一个m行n列的矩阵,而小渊和小轩被安排在矩阵对角线的两端,因此,他们就无法直接交谈了.幸运的是 ...

  3. POJ3714 Raid

    Raid Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 10625   Accepted: 3192 Description ...

  4. 安卓系统源码编译系列(六)——单独编译内置浏览器WebView教程

    原文                   http://blog.csdn.net/zhaoxy_thu/article/details/18883015                 本文主要对从 ...

  5. mysql 高级查询

    高级查询:1.连接查询select * from Info,Nation #这是两个表名,中间用逗号隔开形成笛卡尔积select * from Info,Nation where Info.natio ...

  6. IOS基础之 (三) 类的声明和对象的创建

    一 OC类的声明和实现语法 1.接口的声明 @interface NewClassName: ParentClassName { 实例变量 ... } 方法的声明 ... @end //...表示省略 ...

  7. Spring+Struts2+Mybatis框架搭建时的常见典型问题

    搭建SSM框架时,总是遇到这样那样的问题,有的一眼就能看出来,有的需要经验的积累.现将自己搭建SSM框架时遇到的典型问题总结如下: 一.Struts2框架下的action中无法使用@Autowired ...

  8. enum是不是"继承"int

    enum Color : short { Nono=0, Black=1 } 我们知道基元类型(值类型), 是不可能被继承的,那这里的   :short 到底是什么意思? 我个人理解这里是用来限制取值 ...

  9. iptables一些经常忘掉易混淆的参数

    -A:新增加一条规则,该规则在原规则的最后面 -p:规定应用于哪种数据包,例如:tcp,udp等 -d:(destination),表示目标IP或网络 -s:(source),表示源IP或网络 -j: ...

  10. linux基本命令(1)-用户和组管理

    1.初始化Root密码 sudo passwd 2.切换至Root用户 su - root 或 sudo - i