【杂题】CodeforcesRound #315 (Div. 2)569C Primes or Palindromes?
来源:互联网 发布:工业网络交换机 编辑:程序博客网 时间:2024/06/04 18:06
题目链接
题目大意:令
一道水题。
直接预处理出MAXN以内所有数的
然而蒟蒻一开始以为这个有单调性,幸好有样例三- -
今后打算写二分时一定要先判断单调性!!
我一开始定义
之后仔细一算
以后不能乱跟感觉走,如果是OI赛制就滚粗了- -
#include <iostream>#include <cstdio>#define LL long long int#define MAXN 1200005using namespace std;LL phi[MAXN] ,b[MAXN] ,p ,q ;int num[35] ;bool flag[MAXN] ;bool judge(int x){ int cnt=0 ; while(x) { num[cnt++]=x%10; x/=10; } for(int i=0;i<cnt/2;i++) if(num[i]!=num[cnt-1-i]) return 0; return 1;}void init(){ for(int i=2;i<MAXN;++i) if(!flag[i]) for(int j=i+i;j<MAXN;j+=i) flag[j]=1; for(int i=2;i<MAXN;++i) { phi[i]=phi[i-1]; if(!flag[i])++phi[i]; } for(int i=1;i<MAXN;++i) b[i]=b[i-1]+judge(i);}int main(){ init(); bool flag; while(scanf("%I64d%I64d",&p,&q)!=EOF) { flag=1; for(int i=MAXN-1;i>0;--i) if(q*phi[i]<=p*b[i]) { printf("%d\n",i); flag=0 ; break; } if(flag)puts("Palindromic tree is better than splay tree"); } return 0;}
1 0
- 【杂题】CodeforcesRound #315 (Div. 2)569C Primes or Palindromes?
- C. Primes or Palindromes?-Codeforces Round #315 (Div. 2)
- Codeforces Round #315 (Div. 2) C. Primes or Palindromes?
- Codeforces Round #315 (Div. 2)569C Primes or Palindromes?(预处理)
- Codeforces Round #315 (Div. 2) C. Primes or Palindromes? 素数表 回文数
- Codeforces Round #315 (Div. 2) C. Primes or Palindromes? (素数打表 回文数)
- Codeforces Round #315 (Div. 2) C. Primes or Palindromes? (打表枚举)
- Codeforces Round #315 (Div. 2)——C. Primes or Palindromes?
- Codeforces Round #315 (Div. 2) C - Primes or Palindromes?(暴力打表)
- Codeforces 569C Primes or Palindromes?
- 【34.88%】【codeforces 569C】Primes or Palindromes?
- CodeforcesRound#191(Div.2)
- CodeforcesRound#337(Div. 2)
- CodeForces #315 (div1) A.Primes or Palindromes?
- Primes or Palindromes? CodeForces
- Codeforces Round #315 -Primes or Palindromes?(回文&&素数)
- CodeforcesRound #322 (Div. 2) 解题报告
- codeforce 568A Primes or Palindromes?
- git 更新遇到冲突
- 程序设计模式之设计模式的重大意义
- hdu1048
- java复习-泛型
- CodeForces 429B Working out // 递推dp
- 【杂题】CodeforcesRound #315 (Div. 2)569C Primes or Palindromes?
- makefile中的patsubst
- 结构体字节对齐
- redo和undo的区别
- spring版本区别
- Interesting Integers(CF---BAPC 14 + hnoj11589)扩展欧几里得
- twisted.http 异步访问站点
- 事件模型
- 红杏: 为学者、程序员、外贸工作者打造的上网加速器,专治各种网站打不开和打开慢,而且,更棒的是,红杏按需生效,不影响普通网站的访问速度。 杏不杏?由你红杏: 为学者、程序员、外贸工作者打造的上网加速器