fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define pb push_back
  6. #define mp make_pair
  7. #define ll long long int
  8. #define s(x) scanf("%d", &x)
  9. #define sd(x) scanf("%lf", &x)
  10. #define sl(x) scanf("%lld", &x)
  11. #define mod 1000000007
  12. #define mod1 1000000006
  13. #define get getchar//_unlocked
  14. #define INF 1000000000000000000LL
  15.  
  16. ll a[2000005];
  17. ll b[2000005];
  18. ll prod[2000005];
  19.  
  20. ll power(ll a, ll b)
  21. {
  22. if (!b)
  23. return 1;
  24. ll x = power(a, b>>1);
  25. if (b & 1)
  26. return (((x*x)%mod)*a)%mod;
  27. return (x*x)%mod;
  28. }
  29.  
  30. int main()
  31. {
  32. ll i, type, d, k, n, m, tmpP;
  33. a[0] = a[1] = b[0] = b[1] = 1;
  34. prod[1] = 1;
  35. for (i = 2; i <= 2000000; ++i) {
  36. a[i] = (a[i-1] + (i+1)*a[i-2])%mod;
  37. b[i] = (b[i-1] + i*b[i-2])%mod;
  38. prod[i] = (prod[i-1]*i)%mod;
  39. }
  40. ll q, x, y, z, num, den,tmpN, tmpD;
  41. cin >> q;
  42. while (q--) {
  43. cin >> type >> x >> y >> z;
  44. z %= mod;
  45. if (type == 1) {
  46. if (x == 1)
  47. num = z;
  48. else
  49. num = (((a[x-2] + z*b[x-1])%mod))%mod;
  50. tmpP = (prod[y+1]*power(prod[x], mod-2))%mod;
  51. num = (num * tmpP)%mod;
  52. den = (a[y-1] + z*b[y])%mod;
  53. // cout << num << " " << den << endl;
  54. num = (num * power(den, mod-2))%mod;
  55. cout << num << endl;
  56. }
  57. else {
  58. num = 1;
  59. den = 1;
  60. for (k = 0; k <= y; ++k) {
  61. n = x;
  62. m = (z+k);
  63. if (n == 1) {
  64. tmpN = (m)%mod;
  65. }
  66. else {
  67. tmpN = (((a[n-2] + m*b[n-1])%mod))%mod;
  68. }
  69. tmpP = (n+1);
  70. num = (num * tmpP)%mod;
  71. tmpD = (a[n-1] + m*b[n])%mod;
  72. num = (num * tmpN)%mod;
  73. den = (den * tmpD)%mod;
  74. }
  75. num = (num * power(den, mod-2))%mod;
  76. cout << num << endl;
  77. }
  78. }
  79. return 0;
  80. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/py_compile.py", line 117, in compile
    raise py_exc
py_compile.PyCompileError:   File "prog.py", line 3
    using namespace std;
                  ^
SyntaxError: invalid syntax

stdout
Standard output is empty