#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6+11;
const int N = 1e6;
typedef long long ll;
bitset<maxn> isnprime;
ll prime2[maxn>>2];
int sai(){
isnprime[0]=isnprime[1]=1;
for(int i = 2; i*i < maxn; i++){
if(!isnprime[i]){
for(int j = 2*i; j < maxn; j += i){
isnprime[j]=1;
}
}
}
int cnt=0;
for(int i = 2; i < N; i++) if(!isnprime[i]) prime2[cnt++]=1ll*i*i;
return cnt;
}
ll dfs(ll k,ll n,ll cnt){
ll ans=0;
for(ll i = k; i < cnt && prime2[i] <= n; i++){
ans += n/prime2[i] - dfs(i+1,n/prime2[i],cnt);
}
return ans;
}
int main(){
int cnt=sai();
int T; scanf("%d",&T);
while(T--){
ll n; scanf("%lld",&n);
ll ans = n - dfs(0,n,cnt);
printf("%lld\n",ans);
}
return 0;
}

UESTC - 618的更多相关文章

  1. UESTC 618 无平方因子数 ( 莫比乌斯)

    UESTC 618 题意:求1到n中无平方因子数的个数 Sample Input 3  1  10  30 Sample Output 1  7  19 思路:与前面的BZOJ 2440相似 #inc ...

  2. ACM:UESTC - 649 括号配对问题 - stack

      UESTC - 649  括号配对问题 Time Limit: 1000MS   Memory Limit: 65535KB   64bit IO Format: %lld & %llu ...

  3. UESTC 1015 Lweb and pepper --前,后缀最值

    题意: n种食物,每种含花椒的概率为Pi,现在已经选择了[L,R]这个区间(下标)的食物,要再选一个,使总的食物只有一种含花椒的概率最大,问选哪个最好,相同的选下标小的. 解法: 就不写解法了.此处有 ...

  4. UESTC 1852 Traveling Cellsperson

    找规律水题... Traveling Cellsperson Time Limit: 1000ms Memory Limit: 65535KB This problem will be judged ...

  5. UESTC 1851 Kings on a Chessboard

    状压DP... Kings on a Chessboard Time Limit: 10000ms Memory Limit: 65535KB This problem will be judged ...

  6. UESTC 30 最短路,floyd,水

    最短路 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit Statu ...

  7. The golden ratio: 1.618

    http://www.chinaz.com/design/2015/1109/467968_2.shtml The golden ratio: 1.618 a/b=b/(a+b) The Fibona ...

  8. uestc oj 1218 Pick The Sticks (01背包变形)

    题目链接:http://acm.uestc.edu.cn/#/problem/show/1218 给出n根木棒的长度和价值,最多可以装在一个长 l 的容器中,相邻木棒之间不允许重叠,且两边上的木棒,可 ...

  9. uestc oj 1217 The Battle of Chibi (dp + 离散化 + 树状数组)

    题目链接:http://acm.uestc.edu.cn/#/problem/show/1217 给你一个长为n的数组,问你有多少个长度严格为m的上升子序列. dp[i][j]表示以a[i]结尾长为j ...

随机推荐

  1. JavaWeb中的路径问题

    JavaWEB 开发中的 / 的含义 ①.当前WEB应用的根路径(http://localhost:8080/contextPath/) 请求转发时:request.getRequestDispath ...

  2. 第16章-使用Spring MVC创建REST API

    1 了解REST 1.1 REST的基础知识 REST与RPC几乎没有任何关系.RPC是面向服务的,并关注于行为和动作:而REST是面向资源的,强调描述应用程序的事物和名词. 为了理解REST是什么, ...

  3. 三维GIS

    三维GIS数据结构 三维GIS数据库 三维渲染显示 点云处理 cnki:http://kns.cnki.net/kns/brief/default_result.aspx

  4. 基于HTML5 Ajax文件上传进度条如何实现(jquery版本)

    <!DOCTYPE html> <html> <head> <title>html5_2.html</title> <meta htt ...

  5. try catch finally的用法

    http://hi.baidu.com/vincentwen/blog/item/b92d0923f1e4c64793580757.html try catch finally 1.将预见可能引发异常 ...

  6. 去你妹的DDD 又在误人子弟!

    这种模式只会让人绕弯路 什么聚合根, 什么仓储 ! 实现这些有个J8用? EF本身就是仓储模式 你说是为了切换不同数据库吧 统一事物?我TM 用Sqsugar一样能平滑切换和统一事物,  还不用改代码 ...

  7. angular启动过程

    第一步: .angular-cli.json 第二步: 第三步: 第四步: 第五步:

  8. postgresql删除活动链接的数据库

    当我们在使用drop database testdb命令删除数据库时,会提示该数据库正在被使用,这样我们就无法删除,此时我们可以通过如下语句断开该数据库的所有链接: SELECT pg_termina ...

  9. CentOS 6.3下源码安装LAMP(Linux+Apache+Mysql+Php)环境【转载】

    本文转载自 园友David_Tang的博客,如有侵权请联系本人及时删除,原文地址: http://www.cnblogs.com/mchina/archive/2012/11/28/2778779.h ...

  10. memcached 和 redis 安装

    memcached 1.搭建好lnmp 2.安装依赖包 yum install -y libevent-devel 3.安装memcached $ cd /usr/local/src $ wget h ...