链接:soj
先附个代码:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
typedef __int64 ll ;
const ll mod = 1000000007 ;
int a[7] ;
inline bool get(int &t)
{
bool flag = 0 ;
char c;
while(!isdigit(c = getchar())&&c!='-') if( c == -1 ) break ;
if( c == -1 ) return 0 ;
if(c=='-') flag = 1 , t = 0 ;
else t = c ^ 48;
while(isdigit(c = getchar())) t = (t << 1) + (t << 3) + (c ^ 48) ;
if(flag) t = -t ;
return 1 ;
}
inline ll C(ll n) { return n < 0 ? 0 : ((n+3)*(n+2)*(n+1)/6)%mod; }
inline ll f(ll t)
{
if( t < 0 ) return 0 ;
ll ans = C(t) , i ;
for( i = 4 ; i < 7 ; i++) ans -= C(t-1-a[i]);
ans += C(t-2-a[4]-a[5]) + C(t-2-a[4]-a[6]) + C(t-2-a[5]-a[6]) ;
ans %= mod ;
//printf("ans: %lld\n",ans);
return (ans+mod)%mod ;
}
inline ll CC(ll n) { return n < 0 ? 0 : (n+2)*(n+1)/2 % mod ; }
inline ll func(ll t)
{
if( t < 0 || t > a[1]+a[2]+a[3] ) return 0 ;
ll ans = CC(t) , i ;
for( i = 1 ; i < 4 ; i++) ans -= CC(t-1-a[i]);
ans += CC(t-2-a[1]-a[2]) + CC(t-2-a[2]-a[3]) + CC(t-2-a[1]-a[3]) ;
ans %= mod ;
//printf("ansCC: %I64d\n",ans);
return (ans+mod)%mod ;
}
inline void solve()
{
ll k = ( a[4] + a[5] + a[6] ) , i , ans , sum = (a[1]+a[2]+a[3]) ;
ll fk = f(k) ;
for( i = ans = 0 ; i * 100 <= k && i <= sum ; i++)
{
ans = (ans+func(i)*(fk-f(i*100-1)))%mod ;
}
ans = (ans+mod) % mod ;
printf("%I64d\n",ans);
}
int main()
{
int i , t ;
get(t) ;
while(t--)
{
for( i = 1 ; i <= 6 ; i++) get(a[i]);
solve();
}
}