fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4.  
  5. const int maxn = 600100;
  6. const int mod = 1e9+7;
  7.  
  8. ll fac[maxn+100],inv[maxn+100],power[maxn+100];
  9.  
  10. int a,b,c;
  11.  
  12. ll comb(int a,int b)
  13. {
  14. return fac[a]*inv[b]%mod*inv[a-b]%mod;
  15. }
  16. ll comb(int a,int b,int c)
  17. {
  18. return fac[a+b+c]*inv[a]%mod*inv[b]%mod*inv[c]%mod;
  19. }
  20. int calc(int k)
  21. {
  22. int d = b - c;
  23. int res=0;
  24. for(int t1 = 0;2 * t1 + d <= k;t1++)
  25. {
  26. int t2 = t1 + d;
  27. int t3 = k - t1 - t2;
  28. if(c - t1 - t3 < 0) continue;
  29. res = (res + comb(t1,t2,t3) * comb(c - t1 - t3 + k-1,k-1) % mod * power[t3] % mod)%mod;
  30. }
  31. return res;
  32. }
  33. ll solve(int a)
  34. {
  35. return ((2LL*calc(a)%mod + calc(a+1))%mod + calc(a-1))%mod;
  36. }
  37. int main()
  38. {
  39. fac[0]=1;
  40. for(int i=1;i<=maxn;i++) {
  41. fac[i]=fac[i-1]*i%mod;
  42. }
  43. inv[1]=1;
  44. inv[0]=1;
  45. for(int i=2;i<=maxn;i++) {
  46. inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
  47. }
  48. for(int i=1;i<=maxn;i++) {
  49. inv[i]=inv[i-1]*inv[i]%mod;
  50. }
  51. power[0]=1;
  52. for(int i=1;i<=maxn;i++) {
  53. power[i]=(power[i-1]*2)%mod;
  54. }
  55. while(cin>>a>>b>>c)
  56. {
  57. if(a<c) swap(a,c);
  58. if(a<b) swap(a,b);
  59. if(b<c) swap(b,c);
  60. std::cout << solve(a) << '\n';
  61. }
  62. return 0;
  63. }
Success #stdin #stdout 0s 30128KB
stdin
1 2 1
2 2 2
1 1 10
stdout
6
30
0