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. wifipineapple使用教程

    1.把开关拨到右边 如果有灯亮说明有电 4个灯全亮说明电量是满的 以此类推 如果一个也不亮说明没电了需要用充电器充电 2.把开关拨到左边打开wifi的开关  会开启一个wifi大概一分钟左右会有wif ...

  2. IOS开发之异步加载网络图片并缓存本地实现瀑布流(二)

    /* * @brief 图片加载通用函数 * @parma imageName 图片名 */ - (void)imageStartLoading:(NSString *)imageName{ NSUR ...

  3. [资源] Open source packages on SLAM

    OpenSLAM http://openslam.org/ Most main stream open source slam resource can be found on OpenSLAM, w ...

  4. [bzoj3555]企鹅QQ(hash)

    3555: [Ctsc2014]企鹅QQ Time Limit: 20 Sec  Memory Limit: 256 MBSubmit: 1645  Solved: 616[Submit][Statu ...

  5. Delphi TTable 组件

    TTable 是 TDataSet 的派生类,它是基于 BDE 数据库引擎的数据集组件,也是一个较简单的数据组件,可以直接从数据库中获取数据表的数据,只需设置连接的数据库属性(Database) 和所 ...

  6. java读取配置文件中数据

    Properties pps=new Properties();        try {            pps.load(new FileInputStream("src/emai ...

  7. Software Engineering: 1. Introduction

    Resource: Ian, Sommerville, Software Engineering 1. Professional software development 1.1 Software e ...

  8. 如何解决EditText使用时,点击外侧系统键盘不消失的bug

    在使用viewPager和EditText一起使用的时候,突然出现了一个bug,在点击EditText(此EditText是在ViewPager的Fragment中) 我在切换ViewPager的时候 ...

  9. linux笔记:文件系统管理-分区、文件系统以及文件系统常用命令

    linux分区类型: linux文件系统: df(查看文件系统容量和占用): du(统计文件或目录大小): 查询和自动挂载: 挂载命令格式: 挂载光盘: 卸载光盘: 挂载U盘:

  10. laravel开发微信公众号1 之基本配置

    需要用到的packagist:       https://github.com/overtrue/laravel-wechat  ( 目前最优雅的laravel微信sdk) 首先安装 compose ...