HDU 3835 R(N)
R(N)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2761 Accepted Submission(s):
1420
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).
one integer N(N<=10^9).
6
10
25
65
0
8
12
16
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 <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)的更多相关文章
- 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 ...
- hdu 3835:R(N)(水题,数学题)
R(N) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- H - R(N)
H - R(N) Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Sta ...
- [原]CentOS7安装Rancher2.1并部署kubernetes (二)---部署kubernetes
################## Rancher v2.1.7 + Kubernetes 1.13.4 ################ ##################### ...
- 利用python进行数据分析2_数据采集与操作
txt_filename = './files/python_baidu.txt' # 打开文件 file_obj = open(txt_filename, 'r', encoding='utf-8' ...
- Django项目:CRM(客户关系管理系统)--81--71PerfectCRM实现CRM项目首页
{#portal.html#} {## ————————46PerfectCRM实现登陆后页面才能访问————————#} {#{% extends 'king_admin/table_index.h ...
- POJ 3835 & HDU 3268 Columbus’s bargain(最短路 Spfa)
题目链接: POJ:http://poj.org/problem?id=3835 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=3268 Problem ...
- hdu 4630 查询[L,R]区间内任意两个数的最大公约数
No Pain No Game Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDU 2031 进制转换(10进制转R进制)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2031 进制转换 Time Limit: 2000/1000 MS (Java/Others) M ...
随机推荐
- 使用属性表:VS2013上配置OpenCV
以前,windows下配置OpenCV一直不太方便:总是要手动添加lib,添加include,还要配置PATH使得程序运行时候能找到dll文件. 每次新建一个使用OpenCV的工程都要手动添加,很麻烦 ...
- UVa 11988 Broken Keyboard (a.k.a. Beiju Text)
题目复制太麻烦了,甩个链接 http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18693 直接模拟光标操作时间复杂度较高,所以用链 ...
- “面向对象"和"面向过程"到底有什么区别?
链接:http://www.zhihu.com/question/27468564/answer/101951302 当软件还非常简单的时候,我们只需要面向过程编程: 定义函数函数一函数二函数三函数四 ...
- POJ3041Asteroids(最小点覆盖+有点小抽象)
Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 18289 Accepted: 9968 Descri ...
- 采用post的方式提交数据
1)说明:
- 网络html查看器
1)演示效果:
- 初学JDBC,JDBC工具类的简单封装
//工具类不需要被继承 public final class JdbcUtils{ //封装数据库连接参数,便于后期更改参数值 private static String url="jdbc ...
- day4作业之信息表
实在是太low了,终究是自己写的,记录下 #!/usr/bin/env python # coding=utf8 import os, re #这里我把查询这块分为3个函数了,纠结了很久是放一起还是分 ...
- C语言绘制余弦函数图象
#include"stdio.h" #include"math.h" void main() { double y; int x,m; for(y=1;y> ...
- IIS 7.5 配置10W高并发
原文: http://www.myhack58.com/Article/sort099/sort0100/2012/35585.htm 原文: http://www.myhack58.com ...