H - R(N)

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

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)
 #include<cstdio>
#include<math.h>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int ans=;
for(int i=;i*i<=n;i++)//i是平方因子 {
double m=sqrt(n-i*i);
if(floor(m+0.50)==m) ans++;//floor这个函数是用来判断m 是否是整数,加0.5是用来减少误差的。
}
printf("%d\n",*ans);//每种情况都有四种情况
}
return ;
}

H - R(N)的更多相关文章

  1. Attrib +s +a +h +r 隐藏文件原理与破解

    制作了一个PE启动盘,不过这个启动盘不能深度隐藏,否则没效果,可以又想不让别人看见PE启动盘的一些内容,防止别人误删或者修改,于是就想找一种可以隐藏文件的方法,普通的隐藏文件的方法如下:

  2. python 在头文件添加 #include \"stdafx.h\"\r\n

    import osimport shutil#-*- coding:cp936 -*-import codecsfrom sys import argv def replace_all_files(p ...

  3. 在 .h 和 cpp 中查找 :grep consume ~/test/2016/AMQP-CPP/**/*.cpp ~/test/2016/AMQP-CPP/**/*.h -r

    :grep consume ~/test/2016/AMQP-CPP/**/*.cpp ~/test/2016/AMQP-CPP/**/*.h -r -w "whole" 匹配整个 ...

  4. 如​何​屏​蔽​C​h​r​o​m​e​、​S​a​f​a​r​i​等​W​e​b​k​i​t​内​核​浏​览​器​文​本​框​和​文​本​域​的​高​亮​边​框​、​可​变​大​小​等​自​动​外​观​处​理

    1.高亮外框的取消 input { outline: none; } textarea { outline: none; } 如上,使用CSS的outline就可以实现 2.文本域缩放功能的取消 也是 ...

  5. HDUOJ-------2493Timer(数学 2008北京现场赛H题)

    Timer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  6. Win+R指令(2)

    1. gpedit.msc-----组策略 2. sndrec32-------录音机 3. Nslookup-------IP地址侦测器 ,是一个 监测网络中 DNS 服务器是否能正确实现域名解析的 ...

  7. 使用r.js来打包模块化的javascript文件

    前面的话 r.js(下载)是requireJS的优化(Optimizer)工具,可以实现前端文件的压缩与合并,在requireJS异步按需加载的基础上进一步提供前端优化,减小前端文件大小.减少对服务器 ...

  8. bsxfun.h multiple threads backup

    https://code.google.com/p/deep-learning-faces/source/browse/trunk/cuda_ut/include/bsxfun.h?r=7&s ...

  9. 一些简单二分题,简单的hash,H(i),字符串题

    说在前面: 题是乱七八糟的. 几个二分的题. (但是我的做法不一定是二分,有些裸暴力. 1. Equations HDU - 1496 输入a,b,c,d问你这个方程有多少解.a*x1^2+b*x2^ ...

随机推荐

  1. Codeforces Round #356 (Div. 2)

    A. Bear and Five Cards time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  2. shell中 "" 跟 ''的区别

    在bash里,这两个都是引号,用来表明字符串,区别是,双引号中的变量会被展开,而单引号中不再展开.举个例子:a="abc"echo "str=$a" # 结果显 ...

  3. 简单的SpringMVC的测试项目----跟struts2对比着学习

    一,搭建SpringMVC项目 1,主配置文件-----地基 because,不像struts2是个独立的框架,可以脱离Spring单独使用.需要先添加Spring支持,是Spring框架组成的一部分 ...

  4. 正则表达式获取TABLE里的内容

    //过滤\n 转换成空            String withoutNString=message.Replace("\n", "");          ...

  5. 客户端判断是否为IE9以上版本

    function detectBrowser() { var browser = navigator.appName if(navigator.userAgent.indexOf("MSIE ...

  6. linux下查看某软件是否已安装, ubuntu安装deb包

    1.rpm包安装的,可以用rpm -qa看到,如果要查找某软件包是否安装,用 rpm -qa | grep “软件或者包的名字”. [root@hexuweb102 ~] rpm -qa | grep ...

  7. 【转】Spring jar包详解

    转载自:http://www.cnblogs.com/yanjunwu/archive/2013/04/06/3001927.html org.springframework.aop ——Spring ...

  8. CAD打开文件总是弹出要求选择字体怎么办

    CAD打开文件总是弹出要求选择字体怎么办1.在C:\Documents and Settings\下搜索acad.fmp文件,双击用记事本打开acad.fmp文件,在最后添加内容,上面几行本来就有,不 ...

  9. linux 安装 apache2.2.31

    Linux下安装和配置Apache 概要:本文介绍在CentOS5.4 Linux中安装和配置Apache2.2.14,并且实现Apache和Tomcat6的整合.文章分为三部分,分别是删除系统自带的 ...

  10. Linux 系统目录结构

    登录系统后,在当前命令窗口下输入命令: ls / 你会看到如下图所示: 树状目录结构: 以下是对这些目录的解释: /bin: bin是Binary的缩写, 这个目录存放着最经常使用的命令. /boot ...