/*
* [题意]
* 将一个数拆成四个素数的和,若不可能,则输出"Impossible."
*
* [解题方法]
* 根据哥德巴赫猜想,大于2的偶数能够分成两个素数的和
* (还没完全得到证明,但在题目所给范围内必然成立)
* 利用这个猜想,只要根据输入的奇偶性,定死前两个素数
* 若输入是奇数,则定为2 3 ? ?
* 若是偶数,则定为2 2 ? ?
* 剩余一个偶数再分成两个素数,问题迎刃而解
* PS:显然n<8无解
*/
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
#define M 10000000
int p[665000], vis[M];
int main()
{
int n, i, j, m, k = 0;
for (i = 2; i < M; i++)
{
if (!vis[i])
{
p[k++] = i;
for (j = i+i; j < M; j+=i) vis[j] = 1;
}
}
while (cin >> n)
{
if (n < 8) {
puts("Impossible.");
continue;
}
if (n & 1) cout << 2 << ' ' << 3, n -= 5;
else cout << 2 << ' ' << 2, n -= 4;
for (i = 0; i < k; i++)
if (!vis[n-p[i]])
break;
cout << ' ' << p[i] << ' ' << n-p[i] << endl;
}
return 0;
}
分享到:
相关推荐
V.M. Zolotarev的Modern theory of Summation of Random Variables,找了好久没有电子版,这个版本内部也有Hidden Page, 有需要的凑合着用吧!
Produce a table of the values of the series f(x)=sum(k from 1 to oo)1/(k*(k+x) for the 3001 values of x, x = 0.0, 0.1, 0.2, …, 300.00. All entries of the table must have an absolute error less than ...
Arranged by category, these series include arithmetical and geometrical progressions, powers and products of natural numbers, figurate and polygonal numbers, inverse natural numbers, exponential and ...
傅里叶-拉普拉斯级数Casaro均值的强求和,张微,张希荣,通过连续模界定的$L^{2}(sum_{d})$对数子空间中的傅里叶-拉普拉斯级数的强求和是一个很值得研究的内容。这篇文章经过推导证明得到了凸�
### 不同变量对垂直跳跃高度总体影响的知识点 #### 概述 本文旨在探讨不同变量对垂直跳跃高度总体影响的研究。研究重点在于分析不同的跳跃方式(例如带有反向运动的跳跃)是否会影响个体的垂直跳跃高度。...
1007 Numerical Summation of a Series 简单题,还是蛮有意思的 1045 HangOver 简单题 1049 I Think I Need a Houseboat 简单题 1028 Flip and Shift 简单题,可以DP/BFS/……,但是实际上有数学方法可直接判断...
You'll find a summation of all the skills learned in these chapters in a section called ‘Bringing it all Together’, followed by ‘The Gallery’, a selection of work from fantasy game artists from...
You'll find a summation of all the skills learned in these chapters in a section called ‘Bringing it all Together’, followed by ‘The Gallery’, a selection of work from fantasy game artists from...
% ------ Vertical step ------ for j = 1:N % Find non-zero in the... for k = 1:length(r1) % Update L(qij) by summation of L(rij)\r1(k) Lqij(r1(k) j) = Lci(j) + sum(Lrji(r1 j)) - Lrji(r1(k) j); end % for k
作者: Omar Alonso at the University of Chile, Chile. Introduction Structure of the chapters Naming of variables Probabilities Asymptotic notation About the programming languages On the code ...
非常详尽的数据结构中描述的算法 ...Summation formulas References Textbooks Papers Algorithms coded in Pascal and C Searching algorithms Sorting algorithms Selection algorithms Text algorithms
1003 Numerical Summation of a Series 求最大公因子 math 1004 Anagrams by Stack 给出输入序列和若干输出序列,求栈的处理过程 stack 1005 JUGS 给两杯子,倒出n升水的最少步骤 搜索 1006 Do the Untwist 字符...
Chapter 6 Summation formulas of Poisson and of Plana 6.1 The Poisson summation formula 6.2 Theta transformation formula and functional equation 6.3 The Hurwitz-Lerch zeta-function 6.4 Proof of results...
【求和符号】是数学中的一个基本概念,用于表示一系列项的总和。求和符号通常采用大写的希腊字母Σ(sigma)来表示。在使用求和符号时,它会伴随着一个索引变量,该变量在特定范围内变化,涵盖了所有需要被加起来的...
*summation of*;*sigma* - **乘积符号**:*the product of the terms indicated* - **绝对值**:*the absolute value of* - **平均值**:*the mean value of*;*x bar* - **导数**:*the differential coefficient ...
Fulgide, a kind of thermally irreversible photochromic compound, can be ... which can implement the readout of two individual orthogonal polarized images separately and the subtraction or summation of th
本文主要研究了具有泄漏延迟的不确定递归神经网络(Recurrent Neural Networks, RNNs)的鲁棒稳定性问题。递归神经网络是一种动态的神经网络,广泛应用于时间序列预测、动态系统建模和自然语言处理等领域。...
本项目"coherent_summation_module"很可能是为了解决这类问题提供了一个模块化的解决方案。 在光学领域,相干性是描述光波之间相位关系的一个特性,相干求和涉及到对具有相同频率但相位可能不同的光波进行加法操作...
how to implement some of the power and resource management principles that have been discussed in the document S60 Platform: Effective Power and Resource Management (available at ...
- **Superscripts/Subscripts and Summation Notation:** Introduces common mathematical notations used for indexing and summation, essential for representing complex functions and equations. - **Norm/...