1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 `#include #include using namespace std; typedef long long ll; int p[]={2,3,5,7,11,13,17,89,97, 29,31,37,41,43,47,53,59,61,67,71,73,79,83,19,23}; ll n,m; int d; ll cnt=0,cnt2=0,pw=0; const int T=1000000; int p1[101000],p2[T+10]; ll ret; void dfs1(int d,int x,int y,int v) { cnt++; if (x<=T) p2[x]=x; else p1[pw++]=x; for (int k=d;k