博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Fermat’s Chirstmas Theorem (素数打表的)
阅读量:5236 次
发布时间:2019-06-14

本文共 1633 字,大约阅读时间需要 5 分钟。

                                                                         Fermat’s Chirstmas Theorem
Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu
Submit

Description

In a letter dated December 25, 1640; the great mathematician Pierre de Fermat wrote to Marin Mersenne that he just proved that an odd prime p is expressible as p = a2 + b2 if and only if p is expressible as p = 4c + 1. As usual, Fermat didn’t include the proof, and as far as we know, never
wrote it down. It wasn’t until 100 years later that no one other than Euler proved this theorem.

Input

Your program will be tested on one or more test cases. Each test case is specified on a separate input line that specifies two integers L, U where L ≤ U < 1, 000, 000
The last line of the input file includes a dummy test case with both L = U = −1.

Output

L U x y
where L and U are as specified in the input. x is the total number of primes within the interval [L, U ] (inclusive,) and y is the total number of primes (also within [L, U ]) that can be expressed as a sum of squares.

Sample Input

10 2011 19100 1000-1 -1

Sample Output

10 20 4 211 19 4 2100 1000 143 69
#include
#include
#define N 1000005int prime[100005]; int flag[1000005]; int e; void getP() // 素数打表,找出素数存栈 { int i, j; e = 0; memset(flag, 0, sizeof(flag) ); //标记初始化 for ( i=2; i
=l && prime[i]<=u ) { x++; if(prime[i]%4==1) { y++; } } if(prime[i]>u) break; } if(l<=2 && u>=2) { y++; } printf("%d %d %d %d\n",l, u, x, y ); } return 0; }

 

转载于:https://www.cnblogs.com/yspworld/p/3900513.html

你可能感兴趣的文章
状态模式
查看>>
日期正则
查看>>
树莓派kali开启arp【arpspoof,urlsnarf】
查看>>
Quartz 多个触发器
查看>>
Java基础
查看>>
ArcPy 创建图层空间索引
查看>>
bzoj 2732: [HNOI2012]射箭
查看>>
学习笔记 第八周 第二篇(修改版)
查看>>
FPGA基础学习(9) -- 复位设计
查看>>
NPOI实现excel在线审批签字功能
查看>>
诺基亚:黑莓不错,但Lumia920才是最好的商务机
查看>>
团队任务3:第一次冲刺
查看>>
图遍历问题
查看>>
IOS解析XML
查看>>
Python3多线程爬取meizitu的图片
查看>>
BZOJ2467五角形生成树——数学
查看>>
applicationListener
查看>>
iOS中UIPickerView实现省/市连动
查看>>
Notebook computer(Ubuntu)
查看>>
sdds
查看>>