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. 从svn服务器自动同步到另一台服务器

    需求场景 A commit B post-commit C (workstation) --------------> (svn server) ---------------------> ...

  2. hihocoder #1285 智力竞赛

    传送门 总结: 1.仔细读题 2.仔细分析复杂度 3.不要想当然,乱下结论 时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi.小Ho还有被小Hi强拉来的小Z,准备组队 ...

  3. nuget pack

    nuget spec nuget setApiKey yourkeynuget pack PluginMvc.Framework.csproj -Prop Configuration=Releasen ...

  4. 行为Behavior的使用

    原文地址:http://www.it610.com/article/4918541.htm 行为就是继承yii\base\behavior,可以绑定到任意yii\base\compent实例上,然后这 ...

  5. nginx负载均衡器处理session共享的几种方法(转)

    1) 不使用session,换作cookie 能把session改成cookie,就能避开session的一些弊端,在从前看的一本J2EE的书上,也指明在集群系统中不能用session,否则惹出祸端来 ...

  6. 神秘代码让iPhone微信闪退的解决方法

    14号晚,很多人的微信朋友圈中出现了这样几句话“听说苹果手机点全文就会闪退”,下方有好几行空白,需要点击“全文”才能看到,但是一旦你是在iPhone手机微信上点击“原文”后就直接闪退了,而用Andro ...

  7. java笔记--用ThreadLocal管理线程,Callable<V>接口实现有返回值的线程

    用ThreadLocal管理线程,Callable<V>接口实现有返回值的线程 ThreadLocal在我的笔记"关于线程同步"的第5种方式里面有介绍,这里就不多说了. ...

  8. 在CentOS 7 上搭建LAMP

    导读 要求:httpd的动态和静态资源分为两台主机提供,mysql也用单独一台主机.httpd服务提供虚拟主机,一个虚拟主机用于提供phpMyAdmin:另一个虚拟主机用于提供wordpress.安装 ...

  9. iphone/ipad图标尺寸

    http://www.yixieshi.com/ucd/13759.html APP界面设计规范指导APP设计过程中的设计标准,根据统一的设计标准,使得整个APP在视觉上统一.提高用户对APP的产品认 ...

  10. why we use Symbols in Hash

    Rather than using Strings as the keys in a Hash, it’s better practice to use Symbols. Symbols are ju ...