ural 2070. Interesting Numbers
2070. Interesting Numbers
Memory limit: 64 MB
Input
Output
Samples
input | output |
---|---|
|
|
|
|
|
|
Problem Source: Ural Regional School Programming Contest 2015
- #include <iostream>
- #include <cstdio>
- using namespace std;
- const int N = ;
- typedef long long LL;
- LL l, r;
- LL prime[N];
- int tot;
- bool visit[N];
- inline void input()
- {
- cin >> l >> r;
- }
- inline void solve()
- {
- if(l == r && l == )
- {
- cout << "1\n";
- return;
- }
- LL ans = ;
- if(l == ) l++, ans++;
- for(int i = ; i < N; i++)
- {
- if(!visit[i]) prime[++tot] = i;
- for(int j = ; j <= tot; j++)
- {
- if(prime[j] * i >= N) break;
- visit[prime[j] * i] = ;
- if(!(i % prime[j])) break;
- }
- }
- ans += r - l + ;
- for(int i = ; i <= tot; i++)
- {
- LL now = ;
- int times = ;
- while(now < l) now *= prime[i], times++;
- while(now <= r)
- {
- if(times > && !visit[times + ]) ans--;
- now *= prime[i], times++;
- }
- }
- cout << ans << "\n";
- }
- int main()
- {
- ios::sync_with_stdio();
- input();
- solve();
- return ;
- }
ural 2070. Interesting Numbers的更多相关文章
- URAL 2070 Interesting Numbers (找规律)
题意:在[L, R]之间求:x是个素数,因子个数是素数,同时满足两个条件,或者同时不满足两个条件的数的个数. 析:很明显所有的素数,因数都是2,是素数,所以我们只要算不是素数但因子是素数的数目就好,然 ...
- 【线性筛】【筛法求素数】【约数个数定理】URAL - 2070 - Interesting Numbers
素数必然符合题意. 对于合数,如若它是某个素数x的k次方(k为某个素数y减去1),一定不符合题意.只需找出这些数. 由约数个数定理,其他合数一定符合题意. 就从小到大枚举素数,然后把它的素数-1次方都 ...
- 递推DP URAL 1586 Threeprime Numbers
题目传送门 /* 题意:n位数字,任意连续的三位数字组成的数字是素数,这样的n位数有多少个 最优子结构:考虑3位数的数字,可以枚举出来,第4位是和第3位,第2位组成的数字判断是否是素数 所以,dp[i ...
- 递推DP URAL 1009 K-based Numbers
题目传送门 题意:n位数,k进制,求个数分析:dp[i][j] 表示i位数,当前数字为j的个数:若j==0,不加dp[i-1][0]; 代码1: #include <cstdio> #in ...
- 算法笔记_093:蓝桥杯练习 Problem S4: Interesting Numbers 加强版(Java)
目录 1 问题描述 2 解决方案 1 问题描述 Problem Description We call a number interesting, if and only if: 1. Its d ...
- java实现 蓝桥杯 算法提高 Problem S4: Interesting Numbers 加强版
1 问题描述 Problem Description We call a number interesting, if and only if: 1. Its digits consists of o ...
- Ural 2070:Interesting Numbers(思维)
http://acm.timus.ru/problem.aspx?space=1&num=2070 题意:A认为如果某个数为质数的话,该数字是有趣的.B认为如果某个数它分解得到的因子数目是素数 ...
- URAL 2031. Overturned Numbers (枚举)
2031. Overturned Numbers Time limit: 1.0 second Memory limit: 64 MB Little Pierre was surfing the In ...
- ural 1150. Page Numbers
1150. Page Numbers Time limit: 1.0 secondMemory limit: 64 MB John Smith has decided to number the pa ...
随机推荐
- python基础——多重继承
python基础——多重继承 继承是面向对象编程的一个重要的方式,因为通过继承,子类就可以扩展父类的功能. 回忆一下Animal类层次的设计,假设我们要实现以下4种动物: Dog - 狗狗: Bat ...
- Makefile_:=与=的区别
1."=" make会将整个makefile展开后,再决定变量的值.也就是说,变量的值将会是整个makefile中最后被指定的值.看例子: x = foo y ...
- 413. Arithmetic Slices
/**************************Sorry. We do not have enough accepted submissions.*********************** ...
- EF – 4.CRUD与事务
5.6.1 <Entity Framework数据更新概述> 首先介绍Entity Framework实现CRUD的基本方法,接着介绍了如何使用分部类增强和调整数据实体类的功能与行为特性 ...
- jQueryEasyUi验证
多重验证: { field : 'startPort', title : "起始端口", editor: "text", width : 50, edi ...
- jQuery - 4.简单选择器
4.1 简单选择器 (1) :first 选取第一个元素. (2) :last 选取最后一个元素. (3) :not(选择器) 选取不满足"选择器"条件的元素 (4) ...
- 【PHP&&MySQL详解】
PHP和MySQL是一对好搭档,PHP中有一个很大的扩展库专门针对对MySQL的操作.当然,作为一个PHP程序员,首先对MySQL的增删查改要非常熟悉才行. MySQL数据库的连接数大概在6w个左右, ...
- <转>FreeMarker内置函数
一. Sequence的内置函数1. sequence?first 返回sequence的第一个值.2. sequence?last 返回sequence的最后一个值.3. sequence?reve ...
- HP SAN Switch光纖交換機命令行畫zone
有時候我們無法登陸網頁交互界面去操縱交換機,如下提供了命令行方式從交換機劃zone 1.創建別名 alicreate "SummaryDB_N", "211,14; 21 ...
- phpcms 完美实现 导航栏当前栏目高亮
我们在用phpcms做网站的时候,经常碰到导航栏高亮功能,或者侧栏高亮,这个会涉及到几个问题: .栏目列表页子栏目高亮判断,如果当前页面为子栏目,他的顶级栏目如果在导航栏也要高亮. .内容页高亮,这个 ...