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 ...
随机推荐
- 01_console 你真的了解吗,不曾了解过得console~
对于 console 你只知道 console.log 吗? 那你就 out 啦!!! // 1. 显示信息 console.log('hello'); console.info('信息'); con ...
- PHP计算每月几周,每周的开始结束日期
PHP计算每月几周,每周的开始结束日期 因为项目中需要一个每周工作计算的功能,具体日期的算法是,把每月拆分成几个周,最后一个星期这个月份的天数不够就补上下个月的. 列如今天8月27星期一,这个月有31 ...
- 2018 东北地区大学生程序设计竞赛(ABEHIK)
HDU6500:Problem A. Game with string 题意: 给你一个字符串s以及它的m个子串的首尾位置,现在Alice和 Bob两个人轮流在任一子串的前面或者后面加1个字符,要求加 ...
- Render函数详解
一.虚拟dom DOM是文档对象模型(Document Object Model)的简写,在浏览器中通过js来操作DOM的操作性能很差,于是虚拟Dom应运而生.虚拟Dom就是在js中模拟DOM对象树来 ...
- Spring-cloud微服务实战【六】:接口服务feign
在上一篇文章中,我们使用了ribbon进行负载均衡,但是仔细思考一下,我们的请求封装和调用以及结果的返回都是我们自己编码完成的,如果需要调用的接口很多,那么无疑开发量是比较大的,那有没有比较好的方式呢 ...
- Java入门 - 语言基础 - 02.开发环境配置
原文地址:http://www.work100.net/training/java-environment-setup.html 更多教程:光束云 - 免费课程 开发环境配置 序号 文内章节 视频 1 ...
- spring整合Mybati时,只报空指针异常问题
异常如下: 在整合spring和Mybatis,刚开始进行查询映射时没有问题,在进行插入映射时一直报空指针异常,后来把插入部分的Mapper映射文件和Dao层接口方法删除到原来还是不行,后来网上查了查 ...
- java面试|精选基础(1)
以下题目是从面试经历和常考面试题中选出有点儿意思的题目,参考答案如有错误,请联系小编指正,感谢! 1.反射 1.1定义 JAVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法 ...
- 机器学习环境配置系列一之CUDA
本文配置的环境为redhat6.9+cuda10.0+cudnn7.3.1+anaonda6.7+theano1.0.0+keras2.2.0+jupyter远程,其中cuda的版本为10.0. 第一 ...
- re模块的使用
re模块下的函数 compile(pattern):创建模式对象 import re pat = re.compile('D') m = pat.search('CBA') #等价于re.search ...