NOIP2002 普及組 選數

2021-10-08 13:52:17 字數 783 閱讀 4839

題目描述

已知 n 個整數 x1,x2,…,xn,以及乙個整數 k(k<n)。從 n 個整數中任選 k 個整數相加,可分別得到一系列的和。例如當 n=4,k=3,4 個整數分別為 3,7,12,19 時,可得全部的組合與它們的和為:

3+7+12=22  3+7+19=29  7+12+19=38  3+12+19=34。

現在,要求你計算出和為素數共有多少種。

例如上例,只有一種的和為素數:3+7+19=29)。

輸入鍵盤輸入,格式為:

n , k (1<=n<=20,k<n)

x1,x2,…,xn (1<=xi<=5000000)

輸出螢幕輸出,格式為:

乙個整數(滿足條件的種數)。

樣例輸入

4 33 7 12 19

樣例輸出

1

#include

#include

#include

using namespace std;

int a[20]

;vector<

int>

b;void

choose

(int n,

int k,

int sum)

//else

if(n ==-1

)return

;else

}int

is_prime

(int num)

intmain()

NOIP2002 普及組複賽 第三題 選數

題目描述description 已知 n 個整數 x1,x2,xn,以及乙個整數 k k n 從 n 個整數中任選 k 個整數相加,可分別得到一系列的和。例如當 n 4,k 3,4 個整數分別為 3,7,12,19 時,可得全部的組合與它們的和為 3 7 12 22 3 7 19 29 7 12 1...

NOIP 2002 普及組 數字遊戲

題目鏈結 題目分析 這道題是一道區間dp題,跟能量項鍊還有石子合併差不多,我們用f i j l 表示處理i到j這一區間分為l段所能得到的最大值或是最小值。具體看 程式 include include include include include using namespace std int n,...

Noip 2002 普及組 複賽試題

the first 級數求和 p1035 級數求和 解題報告 double運算即可,注意細節.include using namespace std intmain cout return0 級數求和 the second 選數 p1036 選數 解題報告 將給出的資料做公升序全排列 回溯 將得出的...