题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5879

题意:给你一个n ,求∑(1/k2), k from 1 to n;

n的范围是不知道的,所以可能很大;打表可以看出来当n大于10e6的时候值不变;

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<set>
using namespace std;
#define met(a, b) memset(a, b, sizeof(a))
#define N 1000005
#define INF 0x3f3f3f3f
typedef long long LL;
const LL MAX = 1e9; double sum[N]; char str[N]; int main()
{
for(int i=; i<N; i++)
sum[i] = sum[i-] + 1.0/(1.0*i*i); ///for(int i=50000; i<N; i++)
/// printf("%d %.5f\n", N-1, sum[N-1]); while(scanf("%s", str) != EOF)
{
int len = strlen(str), num = ; if(len > )
{
printf("1.64493\n");
continue;
} for(int i=; i<len; i++)
num = num* + str[i]-''; if(num >= N)
printf("1.64493\n");
else
printf("%.5f\n", sum[num]);
}
return ;
}

最新文章

  1. 我的Android第二章:Android目录结构
  2. SQL Server 百万级数据提高查询速度的方法
  3. Java实现Restful框架Jersey学习
  4. C++ 关联容器
  5. java 15 - 9 集合框架之 栈、队列、数组 和 链表
  6. poj 3311 Hie with the Pie
  7. 如何让Eclipse的智能提示像VS一样霸气
  8. JAVA之数组查询binarySearch()方法详解
  9. windbg 调试技巧
  10. python命令行解析工具argparse模块【5】
  11. 关于AIX lv 4k offset问题初步了解
  12. Char device registration
  13. sqlserver2012安装过程
  14. Nacos系列:基于Nacos的配置中心
  15. iOS系统及客户端软件测试的基础介绍
  16. phpstudy报告80端口被占用
  17. kbmmw 与extjs 通过JSON Base64 显示图片
  18. 如何减少block的嵌套层次?
  19. 如何实用便捷的在本地真机调试WEB端HTML5网页
  20. FAQ: SNMP on NetScaler Appliance

热门文章

  1. ZOJ 3805 (树形DP)
  2. HTML6 展望
  3. Graph database_neo4j 底层存储结构分析(6)
  4. 实例讲解Linux下的makefile
  5. 关于UIWebView的总结
  6. iOS -- MVC的理解
  7. System.getProperty
  8. 如何在URL筛选管理器中过滤不需要的URL
  9. 对于PKI(公钥基础结构)及证书服务的通俗理解
  10. mongodb复制集配置