Table of Contents
猜想
Time Limit 3000ms
Memory Limit 65536K
description
input
output
sample_input
sample_output
hint
source
Home Database Mysql Tutorial [数论] NEFU 2 猜想 筛素数

[数论] NEFU 2 猜想 筛素数

Jun 07, 2016 pm 03:38 PM
limit time transmit prime number

传送门:猜想 猜想 Time Limit 3000ms Memory Limit 65536K description 哥德巴赫(Goldbach ]C.,1690.3.18~1764.11.20)是德国数学家;出生于奥斯别尔(现名加里宁城);曾在英国牛津大学学习;原学法学,由于在欧洲各国访问期间结识了贝努利家族,所以对数

传送门:猜想

猜想

Time Limit 3000ms

Memory Limit 65536K

description

<span>哥德巴赫(Goldbach ]C.,1690.3.18~1764.11.20)是德国数学家;出生于格奥尼格斯别尔格(现名加里宁城);曾在英国牛津大学学习;原学法学,由于在欧洲各国访问期间结识了贝努利家族,所以对数学研究产生了兴趣;曾担任中学教师。1725年,到了俄国,同年被选为彼得堡科学院院士;1725年~1740年担任彼得堡科学院会议秘书;1742年,移居莫斯科,并在俄国外交部任职。
1742年,哥德巴赫在教学中发现,每个不小于6的偶数都是两个素数(只能被1和它本身整除的数)之和。如6=3+3,14=3+11等等。公元1742年6月7日哥德巴赫写信给当时的大数学家欧拉,欧拉在6月30日给他的回信中说,他相信这个猜想是正确的,但他不能证明。叙述如此简单的问题,连欧拉这样首屈一指的数学家都不能证明,这个猜想便引起了许多数学家的注意。从哥德巴赫提出这个猜想至今,许多数学家都不断努力想攻克它,但都没有成功。
我们不需要你去证明哥德巴赫猜想。
如果哥德巴赫猜想是正确的,一个(不小于6的)偶数,都是两个素数之和。那么这个偶数能被至少一个素数对表示,如14,即可以表示为14=3+11,也可以表示为14=7+7。不同的偶数对应的素数对的数目是不一样的,如偶数6,就只能表示为6=3+3。对于每个给定的偶数,我们希望知道有多少素数对的和等于该偶数。
</span>
							
Copy after login

input

<span>有多组测试数据。每组测试数据占一行,包含唯一的一个正偶数n.(6 
							</span>
Copy after login

output

<span>对于每个输入的偶数,输出一行包含唯一的一个整数:表示有多少个素数对的和是输入的偶数。</span>
							
Copy after login

sample_input

<span>6
14</span>
							
Copy after login

sample_output

<span>1
2</span>
							
Copy after login

hint

<span>2009湘潭邀请赛
								</span>
							
Copy after login

source


解题报告:

此题可用Eratosthenes筛法直接写。但是我邪恶了一下。用线性筛法把所有素数筛选出来。然后进行判断。因为是O(n)的算法,所以时间消耗比较少。

代码如下:

#include<iostream>
#include<cstdio>
#include<cstring>
#define maxn 1=prime[i];i++){
            if(!visited[n-prime[i]])
                cnt++;
        }
        printf("%d\n",cnt);
    }
    return 0;
}
</cstring></cstdio></iostream>
Copy after login


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of how to use take and limit in Laravel Detailed explanation of how to use take and limit in Laravel Mar 10, 2024 pm 05:51 PM

"Detailed explanation of how to use take and limit in Laravel" In Laravel, take and limit are two commonly used methods, used to limit the number of records returned in database queries. Although their functions are similar, there are some subtle differences in specific usage scenarios. This article will analyze the usage of these two methods in detail and provide specific code examples. 1. Take method In Laravel, the take method is used to limit the number of records returned, usually combined with the orderBy method.

Monotonic clock processing of time package Monotonic clock processing of time package Aug 04, 2023 pm 05:45 PM

Today we are mainly going to take a look at the time application method of golang time package. The general rule between the two is that "wall time" is used to tell time, and "monotonic clock" is used to measure time; there are other clock processing methods.

Comparison of functions and usage of take and limit in Laravel Comparison of functions and usage of take and limit in Laravel Mar 09, 2024 pm 09:09 PM

Take and limit are two commonly used methods in Laravel to limit the number of query result sets. Although they have certain similarities in functionality, they differ in usage and some details. This article will conduct a detailed comparison of the functions and usage of the two methods, and provide specific code examples to help readers better understand the differences between them and how to apply them correctly. 1.take method The take method is in the LaravelEloquent query builder

How to use Java8 Time API How to use Java8 Time API Apr 28, 2023 pm 12:25 PM

1. Overview As part of this article, let us start with some problems with the existing Date and CalendarAPI and explore how the new Java8Date and TimeAPI solve these problems. We will also take a look at the core classes in the Java8 time class library, such as LocalDate, LocalTime, LocalDateTime, ZonedDateTime, Period, Duration and their APIs. 2. The problem of thread safety of the old time API (before Java 8)-Date and Calendar classes are not thread-safe, making it difficult for developers to debug concurrency problems of these APIs and need to write additional code to deal with them.

How to teleport in Final Fantasy 15 How to teleport in Final Fantasy 15 Mar 08, 2024 am 08:37 AM

Players can quickly switch maps through teleportation when playing in Final Fantasy 15. Many players do not know how to teleport in Final Fantasy 15. Players can use teleportation crystals or use space skills to teleport. How to teleport in Final Fantasy 15: Use teleport crystal or use space skills. 1. Players can use teleportation crystals or space skills to teleport. 2. Players need to hold down the △ key to teleport. 3. Players can also use Chocobo to quickly move to other locations.

A deep dive into the differences between take and limit in Laravel A deep dive into the differences between take and limit in Laravel Mar 10, 2024 pm 01:00 PM

In Laravel, we often use some methods to limit the number of query results, including take and limit methods. While they can both be used to limit the number of query results, they do have some subtle differences. In this article, we'll take a deep dive into how take and limit differ in Laravel, illustrating them with concrete code examples. First, let's look at the take method. The take method is part of Eloquent and is typically used for

How to use the limit and skip functions of Stream in Java for stream operations How to use the limit and skip functions of Stream in Java for stream operations Jun 26, 2023 pm 03:55 PM

StreamAPI was introduced in Java 8, which can greatly simplify the operation of collections. The Stream class provides many functional methods for operating on streams, including filtering, mapping, merging, and more. Among them, limit and skip are two functions used to limit the number of elements in stream operations. 1. Limit function The limit function is used to limit the number of elements in the stream. It accepts a long type parameter n, which represents the number of limits. After calling the limit function, a new stream is returned, which only contains

What is the difference and usage between time and datetime in python What is the difference and usage between time and datetime in python May 02, 2023 am 11:01 AM

1. Two ways to represent time in Python: timestamp: offset in seconds relative to 1970.1.100:00:00, unique time tuple struct_time: a total of 9 elements>tm_year: year 1-12> tm_mon: month 1-12>tm_mday: day 1-31>tm_hour: hour 0-23>tm_min: minute 0-59>tm_sec: second 0-59>tm_wday: week 0-6 (0 means Sunday)>tm_day: Day of the year 1-366>tm_isdst: whether it is daylight saving, the default is -1.ti

See all articles