#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. Python程序调试-TabError: inconsistent use of tabs and spaces in indentation

    报错信息:TabError: inconsistent use of tabs and spaces in indentation 说明:代码缩进统一使用Tab键或空格键,不能混用. 解决办法: 1. ...

  2. Fedora 16下安装ruby on rails

    Fedora 16下安装ruby on rails 最近在windows下写了些rails小程序,问题一个接一个,到最后终于坚信了那句话“windows不适合用于ruby on rails开发”.于是 ...

  3. c语言实践:RS信号报告

    题目: 无线电台的RS制信号报告是由三两个部分组成的: R(Readability) 信号可辨度即清晰度. S(Strength)    信号强度即大小. 其中R位于报告第一位,共分5级,用1—5数字 ...

  4. Windows Cmder

    一.简介 作为一个程序员,即使是在windows工作环境,cmd也是我们必不可少的使用工具.cmder 是为 Windows 提供的一个便携式控制台仿真器,用来替代windows的cmd,使用非常简单 ...

  5. T-SQL分页功能存储过程

    分页功能存储过程 ALTER PROCEDURE [dbo].[P_SplitPagesQuery] @TablesName NVARCHAR(MAX),--表名或视图名(只能传单一表名) @PK N ...

  6. .Net插入大批量数据

    1. 使用SqlDataAdapter /// <summary>        /// 实现数据库事务,大批量新增数据        /// </summary>       ...

  7. python 单双引号交替的json串

    单双引号交替的json串 1.常见的json串,类似于这种{"isSucess":true, "name":"yoyo", "st ...

  8. MVC - Routing - 网址路由

    1. Routing  : 路由 主要是比对通过浏览器传来的http要求与响应适当的网址给浏览器. @Html.ActionLink("关于","About", ...

  9. 11款PHP集成开发环境

    1. Zend Studio Zend Studio 来自 Zend —— PHP 幕后的精英团队. 它真的是很不错.它运行于三大系统:Windows.Mac OS X 和 Linux.而且绝对能够提 ...

  10. LoadRunner--获取请求的返回结果函数

    注:内容来自网络 Action(){ web_set_max_html_param_len("262144"); // 默认最大长度为256 web_reg_save_param( ...