time limit: 1 sspace limit: 128000 KBtitle level: Golden Gold
Title Description Description
n integers are known to x1,x2,..., xn, and an integer k (k 3+7+12=22 3+7+19=29 7+12+19=38 3+12+19=34.
Now, ask you to figure out how many kinds of numbers are in total.
For example, in the above example, there is only one and a prime number: 3+7+19=29).
Enter a description input Description
Keyboard input, in the form of:
N, K (1<=n<=20,k X1,X2,...,XN (1<=xi<=5000000)
outputs description output Description
Screen output in the form of:
An integer (the number of species that satisfies the condition).
sample input to sample
4 3
3 7 12 19
Sample output Sample outputs
1
data size & Hint
(1<=n<=20,k (1<=xi<=5000000)
Portal point This expansion
The Simple BFS
#include <iostream>using namespacestd;intk,a,b,c,d,m;Charju[ -][ -];intfx[4]={0,0,-1,1},fy[4]={1,-1,0,0};BOOLssintAintb) { intHead=0, tail=1, f[ -][2],x,y; f[tail][1]=A; f[tail][2]=b; JU[A][B]='#'; Do{Head++; for(intI=0;i<4;++i) {x=f[head][1]+Fx[i]; Y=f[head][2]+Fy[i]; if(x>=0&&y>=0&&x<k&&y<k&&ju[x][y]=='.') {Tail++; f[tail][1]=x; f[tail][2]=y; Ju[x][y]='#'; } } } while(head<tail);}intMain () {intH=0; CIN>>m; while(h<m) {h++; CIN>>K; for(intI=0; i<k;++i) { for(intj=0; j<k;++j) {cin>>Ju[i][j]; if(ju[i][j]=='s') {a=i; b=J; JU[I][J]='.'; } if(ju[i][j]=='e') {C=i; D=J; JU[I][J]='.'; }}} SS (A, B); if(ju[c][d]=='#') cout<<"YES"<<Endl; Elsecout<<"NO"<<Endl; }}
Codevs 1215 Maze