hdu 3835 简单概率dp
来源:互联网 发布:长笛 知乎 编辑:程序博客网 时间:2024/04/27 18:34
R(N)
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 3 Accepted Submission(s) : 1
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).
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
26102565
Sample Output
4081216HintFor 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<cstdio>#include<cstring>#include<cmath>#include<algorithm>using namespace std;int n;int main(){ while(scanf("%d",&n)!=EOF) { if(!n) { printf("1\n"); continue; } int i,j,ans=0,ave=(int)sqrt(double(n/2.0)); for(i=ave; i>=0; i--) { j=(int)sqrt(1.0*(n-i*i)); if(i*i+j*j==n) { if(i==0||j==0||i==j) ans+=4; else ans+=8; } } printf("%d\n",ans); } return 0;}/*26102565*/
Source
2011 Multi-University Training Contest 1 - Host by HNU
- hdu 3835 简单概率dp
- hdu 3853 概率DP 简单
- hdu 4405 简单概率dp
- hdu 3835 概率DP
- HDU 4546简单的概率 dp
- 简单概率dp(期望)-hdu-3853-LOOPS
- hdu 4405(概率dp简单题)
- HDU 3853 LOOPS (简单概率DP)
- LOOPS+hdu+简单概率期望dp
- HDU - 3853(简单概率dp , 注意边界)
- HDU 3853 LOOPS [简单概率DP]
- hdu football 概率DP
- hdu 3853 概率DP
- hdu Robberies 概率DP
- hdu 4405 概率DP
- HDU 3853 概率DP
- hdu 4487 概率DP
- hdu 4089 概率dp
- linux 环境变量设置方法总结(PATH/LD_LIBRARY_PATH)
- 递归与分治之整数划分
- 高级 inline hook 技术
- C++实现观察者模式—2
- 十月7日
- hdu 3835 简单概率dp
- VS2010优秀插件
- 十招教你从程序员转向企业家
- 大数加法.减法.乘法.除法
- modbus协议功能码和常见问题
- queue的实现 数据结构
- sql server 数据库加强3
- 关于如何抵抗压力的10点建议
- samba服务配置(ubuntu 11.10试,可用)