原题地址

简单动归+素数判定,没用筛法也能过

代码:

 #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std; #define MAX_N 64
#define MAX_M 1000000 int T, N;
int cnt[MAX_N];
int p[MAX_M]; int is_prime(int n) {
for (int i = ; i * i <= n; i++)
if (n % i == )
return ;
return ;
} int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
p[] = ;
for (int i = ; i < MAX_M; i++)
p[i] = p[i - ] + is_prime(i);
cin >> T;
while (T--) {
cin >> N;
memset(cnt, , sizeof(cnt));
cnt[] = ;
for (int i = ; i <= N; i++)
cnt[i] = cnt[i - ] + (i - >= ? cnt[i - ] : );
cout << p[cnt[N]] << endl;
}
return ;
}

最新文章

  1. dom 操作
  2. OstrichNet 简易统计信息收集工具
  3. 简单的方向传感器SimpleOrientationSensor
  4. #!/usr/bin/env python与#!/usr/bin/python的区别
  5. log4j配置文件详解
  6. centos上手动编译安装tmux的问题
  7. python_递归
  8. hdu 5326 Work
  9. css属性
  10. 2014年辛星完全解读Javascript第二节
  11. Java JSON序列化杂谈
  12. css(html)背景图优化合并
  13. Python安装及开发环境配置
  14. 线段树解Insertion Sort Advanced Analysis
  15. 简单的刷票系统(突破IP限制进行投票) (转)
  16. 201521123045 《JAVA程序设计》第1周学习总结 1
  17. Angular Universal(统一平台)笔记
  18. 记录日常Linux常用软件
  19. 媒体查询@media 屏幕适配
  20. office2013 Word 缺少校对工具,按提示下载、安装了文件还是不成功的解决方案

热门文章

  1. log日志应用 自定义的log
  2. 自定义可伸缩的imageView
  3. [windows]桌面中添加我的电脑,我的文档和网上邻居图标
  4. Struts2标签&lt;s:checkboxlist&gt;回显问题
  5. 使用javap深入理解Java整型常量和整型变量的区别
  6. linux下使用OpenCV的一些问题
  7. Asp.Net Core 入门(九)—— 环境变量 TagHelper
  8. python matplotlib.pyplot对图像进行绘制
  9. CPP-网络/通信:COM
  10. RedHat7搭建KVM虚拟机