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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 `#include using namespace std; long long MOD = 1000000007ll; long long n; string k[4]; long long r[4]; long long P1[10001]; long long P2[10001]; long long P3[10001]; long long P3S[10001]; long long PA[10001]; long long PB[10001]; long long PC[10001]; long long PD[10001]; long long PDS[10001]; void binomialCoeff(int nn, int kk, long long C[]) { for (int i = 0; i <= nn; i++)C[i]=0; C[0] = 1; // nC0 is 1 for (int i = 1; i <= nn; i++) { for (int j = min(i, kk); j > 0; j--) { C[j] = C[j] + C[j-1]; C[j]%=MOD; } } // cout<<"\nPIT: "; // for (int i = 0; i <= nn; i++) { cout< r[a] || r2>r[b])continue; // cout<<"G: "<r[2])break; for(long long k = min((r[3]+i-a-c)/2ll,min(i-j,b)); k>= 0; k--) { // if((2*k-i+a+c)>r[3])break; ile2++; long long l = i-j-k; if(l>=0 && l<=c ){ r1 = r[1]-i; r2 = r[2]-(j+(b-k)+(c-l)); r3 = r[3]-((a-j)+k+(c-l)); if(r1>=0 && r2>=0 && r3>=0){ // cout<<"i: "<>n; binomialCoeff(n,n,P1); cin>>r[1];cin>>k[1]; cin>>r[2];cin>>k[2]; cin>>r[3];cin>>k[3]; if(r[1]>r[2]){ swap(r[1],r[2]); swap(k[1],k[2]); } if(r[1]>r[3]){ swap(r[1],r[3]); swap(k[1],k[3]); } if(r[2]>r[3]){ swap(r[2],r[3]); swap(k[2],k[3]); } long long F1 = F(r[1]); long long F2 = F(r[2]); long long F3 = F(r[3]); //cout<<"F_1: "<