UESTC - 618
#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的更多相关文章
- UESTC 618 无平方因子数 ( 莫比乌斯)
UESTC 618 题意:求1到n中无平方因子数的个数 Sample Input 3 1 10 30 Sample Output 1 7 19 思路:与前面的BZOJ 2440相似 #inc ...
- ACM:UESTC - 649 括号配对问题 - stack
UESTC - 649 括号配对问题 Time Limit: 1000MS Memory Limit: 65535KB 64bit IO Format: %lld & %llu ...
- UESTC 1015 Lweb and pepper --前,后缀最值
题意: n种食物,每种含花椒的概率为Pi,现在已经选择了[L,R]这个区间(下标)的食物,要再选一个,使总的食物只有一种含花椒的概率最大,问选哪个最好,相同的选下标小的. 解法: 就不写解法了.此处有 ...
- UESTC 1852 Traveling Cellsperson
找规律水题... Traveling Cellsperson Time Limit: 1000ms Memory Limit: 65535KB This problem will be judged ...
- UESTC 1851 Kings on a Chessboard
状压DP... Kings on a Chessboard Time Limit: 10000ms Memory Limit: 65535KB This problem will be judged ...
- UESTC 30 最短路,floyd,水
最短路 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit Statu ...
- 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 ...
- uestc oj 1218 Pick The Sticks (01背包变形)
题目链接:http://acm.uestc.edu.cn/#/problem/show/1218 给出n根木棒的长度和价值,最多可以装在一个长 l 的容器中,相邻木棒之间不允许重叠,且两边上的木棒,可 ...
- uestc oj 1217 The Battle of Chibi (dp + 离散化 + 树状数组)
题目链接:http://acm.uestc.edu.cn/#/problem/show/1217 给你一个长为n的数组,问你有多少个长度严格为m的上升子序列. dp[i][j]表示以a[i]结尾长为j ...
随机推荐
- mongo状态查看方法
列举一些常用的mongodb状态查看方法. 1.mongostat 是mongdb自带的状态检测工具, inserts/s 每秒插入次数 query/s 每秒查询次数 update/s 每秒更新次数 ...
- 面试题:缓存Redis与Memcached的比较 有用
Memcached是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载. 它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提供动态.数据库驱动网站的速度. Memca ...
- #Pragma Pack与内存分配
博客转载自:https://blog.csdn.net/mylinx/article/details/7007309 #pragma pack(n) 解释一: 每个特定平台上的编译器都有自己的默认“对 ...
- SQLAlchemy 进阶
SQLAlchemy使用 1.执行原生SQL语句 from sqlalchemy.orm import sessionmaker from sqlalchemy import create_engin ...
- httpClient-3.1学习笔记
http://hc.apache.org/httpclient-3.x/tutorial.htmlThe general process for using HttpClient consists o ...
- <%@ include > 与< jsp:include >
include指令表示在JSP编译时插入一个包含文本或者代码的文件,把文件中的文本静态地包含过去.也就是说,会把被包含的页面拷贝到包含的页面中指令所在的位置. 语法格式:<%@ include ...
- Backbone.js 0.9.2 中文解释
// Backbone.js 0.9.2 // (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc. // Backbone may be freely ...
- C# DataGridView控件动态添加新行
C# DataGridView控件动态添加新行 DataGridView控件在实际应用中非常实用,特别需要表格显示数据时.可以静态绑定数据源,这样就自动为DataGridView控件添加相应的行.假如 ...
- Insus.NET最近想更换一部手机
Insus.NET曾经使用过好几部手机.给Insus.NET工作与生活上带来了方便.最近想更换一部新手机,因此记念一下以前使用过的手机.当时Insus.NET没有相机,下面图片是网上找的(前四部): ...
- 浅谈 kubernetes service 那些事(上篇)
一.问题 首先,我们思考这样一个问题: 访问k8s集群中的pod, 客户端需要知道pod地址,需要感知pod的状态.那如何获取各个pod的地址?若某一node上的pod故障,客户端如何感知? 二.k8 ...