WeChall_Prime Factory (Training, Math)
Your task is simple:
Find the first two primes above 1 million, whose separate digit sums are also prime.
As example take 23, which is a prime whose digit sum, 5, is also prime.
The solution is the concatination of the two numbers,
Example: If the first number is 1,234,567
and the second is 8,765,432,
your solution is 12345678765432
解题:
素数打表,依次从小到达剔除素数的倍数的数。
def allsum(x):
sum = 0
while x:
sum += x%10
x //= 10
return sum total = 2000000
prime = []
a = [1 for i in range(total)]
for i in range(2,total):
if a[i]:
prime.append(i)
time = 2
while 1:
num = time*i
if num >= total:
break
a[num] = 0
time += 1 find = 0
for i in range(1000000,total):
if i in prime and allsum(i) in prime:
print(i)
find += 1
if find == 2:
break
WeChall_Prime Factory (Training, Math)的更多相关文章
- WeChall_Prime Factory (Training, Math)Training: WWW-Robots (HTTP, Training)
In this little training challenge, you are going to learn about the Robots_exclusion_standard.The ro ...
- We Chall-Prime Factory-Writeup
MarkdownPad Document html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,ab ...
- wechall前十题
今天开始打一打wechall 累了打wechall,不累的时候开始打buu 第一题:Get Sourced 查看源代码即可,拉到底部 第二题:Stegano 属于misc的范畴,直接下载下来,然后no ...
- 0x00 Wechall writeup
目录 0x00 Wechall writeup Training: Get Sourced Training: ASCII Encodings: URL Training: Stegano I Tra ...
- HDU 6063 - RXD and math | 2017 Multi-University Training Contest 3
比赛时候面向过题队伍数目 打表- - 看了题解发现确实是这么回事,分析能力太差.. /* HDU 6063 - RXD and math [ 数学,规律 ] | 2017 Multi-Universi ...
- 2017 Multi-University Training Contest - Team 3——HDU6063 RXD and math
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6063 题目意思:字面意思,给出n,k,算出这个式子的答案. 思路:比赛的时候是打表找规律过了,赛后仔细 ...
- 【模拟退火】Petrozavodsk Winter Training Camp 2017 Day 1: Jagiellonian U Contest, Monday, January 30, 2017 Problem F. Factory
让你在平面上取一个点,使得其到给定的所有点的距离和最小. 就是“费马点”. 模拟退火……日后学习一下,这是从网上扒的,先存下. #include<iostream> #include< ...
- 【2017 Multi-University Training Contest - Team 3】RXD and math
[Link]: [Description] [Solution] 发现1010mod(109+7)=999999937; 猜测答案是nk 写个快速幂; 注意对底数先取模; [NumberOf WA] ...
- 2014 Multi-University Training Contest 9#6
2014 Multi-University Training Contest 9#6 Fast Matrix CalculationTime Limit: 2000/1000 MS (Java/Oth ...
随机推荐
- 接口自动化测试框架 -- reudom
reudom Automated testing framework based on requests and unittest interface. 基于 Unittest 和 Requests ...
- Win10该文件没有与之关联的应用来执行该操作...请在"默认应用设置"页面中创建关联
问题发现:一直使用的一款软件--火柴,这两天忽然发现通过ctrl + 回车快捷键无法进入到文件所在的目录中(之前几天印象中还可以使用该功能).后来测试又发现无法打开网易云音乐中下载的音乐而进入到该音乐 ...
- 查找2-n之间素数的个数
题目描述 查找2-n之间素数的个数.n为用户输入值.素数:一个大于1的正整数,如果除了1和它本身以外,不能被其他正整数整除,就叫素数.如2,3,5,7,11,13,17…. 输入 整数n 输出 2-n ...
- React-router路由4.0版本用法
第一步:引包两个 命令:cnpm i -S react-router react-router-dom 第二步:用路由管理APP页面 1.创建主路由管理页面,在这里使用了路由嵌套 import Rea ...
- Java爬虫一键爬取结果并保存为Excel
Java爬虫一键爬取结果并保存为Excel 将爬取结果保存为一个Excel表格 官方没有给出导出Excel 的教程 这里我就发一个导出为Excel的教程 导包 因为个人爱好 我喜欢用Gradle所以这 ...
- 从源码角度来看BeanFactory和ApplicationContext的关系
大家好,我是小黑,这是年前的最后一篇推文,提前祝大家新年快乐~~ 这次我们从源码角度来聊聊BeanFactory和ApplicationContext的关系,讲一些网上文章不曾提到的点. 官方描述 先 ...
- 小白学 Python 爬虫(40):爬虫框架 Scrapy 入门基础(七)对接 Selenium 实战
人生苦短,我用 Python 前文传送门: 小白学 Python 爬虫(1):开篇 小白学 Python 爬虫(2):前置准备(一)基本类库的安装 小白学 Python 爬虫(3):前置准备(二)Li ...
- Scala与Mongodb实践1-----mongodbCRUD
目的:如何使用MongoDB之前提供有关Scala驱动程序及其异步API. 1.现有条件 IDEA中的:Scala+sbt+SDK mongodb-scala-driver的网址:http://mon ...
- 初识 ST 表
推荐博客 : https://blog.csdn.net/BerryKanry/article/details/70177006 ST表通常用于RMQ问题中,询问某个区间的最值这类问题中 ST表的核心 ...
- SPSS 相关性的选择
在SPSS中导入数据,analyze-correlate-bivariate-选择变量 OK 输出的是相关系数矩阵 相关系数下面的Sig.是显著性检验结果的P值,越接近0越显著. 同样的数据,我们接着 ...