WeChall writeup :Prime Factory
来源:互联网 发布:送男朋友什么礼物 知乎 编辑:程序博客网 时间:2024/06/12 01:40
题目:Prime Factory
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
解题:
找到两个质数,满足:
1.大于1000000
2.各位数字合也是质数。如23是质数,2+3=5也是质数。
写一段C程序,solution:10000331000037
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> int isprime1(int num){for(int m=2;m<=sqrt(num);m++){if(num%m==0)return 0; //num不是质数}return 1;//num是质数}int isprime2(int num){int sum=0;while(num){sum+=num%10;num/=10;}if(isprime1(sum))return 1; //各位数字之和仍为质数elsereturn 0;} int main() { int i; char temp[100]= ""; FILE*fp=fopen("prime1.txt","w"); for(i=3;i<1000100;i+=2) { if(i>1000000){ if(isprime1(i))if(isprime2(i)){sprintf(temp, "%d\n", i);fwrite(temp,1,strlen(temp),fp); }} } fclose(fp); printf("DONE!!\n"); return 0; }
阅读全文
0 0
- WeChall writeup :Prime Factory
- WeChall:Prime Factory
- WeChall -Prime Factory-python
- We Chall-Prime Factory-Writeup
- WeChall mysql WriteUp
- Wechall PHP Writeup
- WeChall Exploit writeup
- Writeup For WeChall
- WeChall writeup :Encodings I
- wechall writeup:Programming 1
- Wechall writeup By Assassin
- 渗透测试演练平台RedTigers Hackit通关writeup以及wechall平台介绍
- WeChall - overthewire
- WeChall Training: Get Sourced
- WeChall Training: Stegano I
- WeChall Training: WWW-Robots
- WeChall Training: ASCII
- WeChall Encodings: URL
- mcrypt加解密
- MemcachedClient 过期时间设置 expire
- 二叉树的前序遍历
- js获取节点元素
- javaScript及jquery的代码跟踪及调试
- WeChall writeup :Prime Factory
- Hibernate三种状态的区分,以及save,update,saveOrUpdate,merge等的使用
- okhttp源码分析
- 作业-创建数组随机生成30个不重复数字进去-在随机出来5个-然后排序输出
- java poi 合并单元格
- CSDN学院--人工智能真的能取代人类??
- PAT 1002. 写出这个数 (20) —— Java
- php 判断 变量是数值还是字符串以及 empty、isset的区别
- 第一个Node.js程序——Hello World