ural 2070. Interesting Numbers
2070. Interesting Numbers
Memory limit: 64 MB
Input
Output
Samples
| input | output |
|---|---|
3 7 |
4 |
2 2 |
1 |
77 1010 |
924 |
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 ...
随机推荐
- 赛车比赛(洛谷U4566)
题目背景 kkk在赛车~ 题目描述 现在有N辆赛车行驶在一条直线跑道(你可以认为跑道无限长)上.它们各自以某种速度匀速前进,如果有两辆车A车和B车,A车在B车的后面,且A车的速度大于B车的速度,那么经 ...
- mybatis配置问题
//当构造函数有多个参数时,可以使用constructor-arg标签的index属性,index属性的值从0开始. <bean id="sqlSession" class= ...
- Linux下第一次使用MySQL数据库,设置密码
在终端下输入:/etc/rc.d/init.d/mysqld status 查看MySQL状态,看看是否运行. 没有运行的话就输入:/etc/rc.d/init.d/mysqld start 这时,就 ...
- hdu 2476 String Painter
第一道区间dp题,感觉题意不是很好理解 题意:一次可以转换某一个位置的字符,或是一串连续的字符,举第一个例子zzzzzfzzzzz 1:aaaaaaaaaaa 2: abbbbbbbbba 3: ab ...
- json数据类型
JSON 语法规则 JSON 语法是 JavaScript 对象表示法语法的子集. 数据在名称/值对中 数据由逗号分隔 花括号保存对象 方括号保存数组 JSON 名称/值对 JSON 数据的书写格式是 ...
- 继续Get News List
拿到news list 所需要的技能 json数组反序列化 iOS中有哪些集合对象 数组的遍历 Debugging with GDB json数组反序列化 id jsonObject = [NSJSO ...
- wp8 入门到精通 MultiMsgPrompt
List<NotifyMsg> arraymsg = new List<NotifyMsg>(); List<NotifyInfo> ArrayNotifyInfo ...
- iphone手机不同版本兼容、横竖屏
/* 兼容问题*/ @media screen and (device-width: 320px) and (device-height: 480px) and (-webkit-device-pix ...
- Android中log使用方法
private static final String ACTIVITY_TAG="MainActivity"; Log.v(MainActivity.ACTIVITY_TAG, ...
- Javaweb三大组件之过滤器filter
Filter的三个方法 void init(FilterConfig):在Tomcat启动时被调用: void destroy():在Tomcat关闭时被调用: void doFilter(Servl ...