Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <string.h>
  5. #include <algorithm>
  6. #include <vector>
  7. #include <string>
  8. #include <stack>
  9. #include <queue>
  10. #include <set>
  11. #include <map>
  12. #include <iostream>
  13. #include <functional>
  14. #include <time.h>
  15. #include <cmath>
  16. #include <deque>
  17.  
  18. using namespace std;
  19.  
  20. #define ll long long
  21. #define mp make_pair
  22. #define pb push_back
  23. #define ld long double
  24. #pragma comment(linker, "/STACK:36777216")
  25.  
  26.  
  27.  
  28. ll EPS = 1000000007;
  29. double PI = 3.14159265358979323846;
  30. const int MAXN = 1000010;
  31.  
  32.  
  33. ll abss(ll h)
  34. {
  35. if (h < 0)
  36. {
  37. return -h;
  38. }
  39. return h;
  40. }
  41.  
  42. __int64 ceill(__int64 x, __int64 y)
  43. {
  44. if (x % y != 0)
  45. {
  46. return (x / y) + 1;
  47. }
  48. return x / y;
  49. }
  50.  
  51.  
  52. int n, m, k;
  53.  
  54. ll a[MAXN];
  55. ll b[MAXN];
  56.  
  57.  
  58.  
  59.  
  60. char q[100];
  61.  
  62. int main()
  63. {
  64. //freopen("strings.in", "r", stdin);
  65. //freopen("strings.out", "w", stdout);
  66. int n;
  67. cin >> n;
  68. int x;
  69. for (int i = 0; i < n; i++)
  70. {
  71. cin >> a[i];
  72. }
  73. b[0] = a[0];
  74. for (int i = 1; i < n; i++)
  75. {
  76. b[i] = b[i - 1] + a[i];
  77. }
  78. ll count = 0;
  79. for (int i = 0; i < n - 2; i++)
  80. {
  81. for (int j = i + 1; j < n - 1; j++)
  82. {
  83. count += (a[i] * a[j] * (b[n - 1] - b[j])) % EPS;
  84. count %= EPS;
  85. }
  86. }
  87. cout << count;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement