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. Swift高级语法学习总结

    Swift基础语法学习总结Swift高级语法学习总结Swift语法总结补充(一) 1.函数 1.1 func funcNmae()->(){} 这样就定义了一个函数,它的参数为空,返回值为空,如 ...

  2. Bootstrap_警示框

    一.默认警示框 Bootstrap框架通过“alert“样式来实现警示框效果.在默认情况之下,提供了四种不同的警示框效果: 1.成功警示框:告诉用用户操作成功,在“alert”样式基础上追加“aler ...

  3. Training

    Purley Skylake RAS training: https://cisco.webex.com/ciscosales/lsr.php?RCID=8042a15a27aa46509a91d8f ...

  4. Postman Postman测试接口之POST提交本地文件数据

    举例: 文件同步接口 接口地址:http://183.xxx.xxx.xxx:23333/ditui/fileupload HTTP请求方式:POST 针对上述这种POST本地文件的接口,接口数据咋提 ...

  5. ubuntu14.04纯命令行下连接有线网和无线网

    在ubuntu下网络管理器Network Manager莫名奇妙出现无法连接无线网的情况,于是昨天就开始着手解决这一问题: 一 :卸载 1.第一步卸载Network-Manager (具体字母的大小写 ...

  6. php : 匿名函数(闭包) [二]

    摘自: http://www.cnblogs.com/yjf512/archive/2012/10/29/2744702.html php的闭包(Closure)也就是匿名函数.是PHP5.3引入的. ...

  7. Java使用BigDecimal精确计算的简单公式计算器

    由于工作需要,写了一个使用BigDecimal运算的精确计算的计算器(然后发现其实比不用BigDecimal的并好不到哪里去) 只能做加减乘除 double类型的数字在千万级别的时候会转成科学计数法, ...

  8. Trick

    1. var b = a.slice(beginIndex,endIndex); [].slice.call( [] ) Array.prototype.slice.call([]) will cop ...

  9. Caché数据库学习笔记(3)

    目录 Query函数及其测试 重建索引表 Management portal简介 远程访问Ensemble ============================================== ...

  10. Android开发--Layout元素

    1.TF类型 android:layout_alignParentStart="true/flase":贴紧父元素的左边缘 android:layout_alignParentEn ...