Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. typedef long long  ll;
  7. typedef unsigned long long ull;
  8. typedef map <int, int> mii;
  9. typedef pair <int, int> pii;
  10. typedef pair <ll, ll> pll;
  11.  
  12. int const maxn = int(1e5 + 12);
  13. int const maxb = int(2e6 + 12);
  14. int const inf = int(1e9 + 7);
  15. ll const linf = ll(1e18 + 12);
  16. double const eps = 1e-7;
  17. double const pi = acos(-1);
  18. #ifdef _WIN32
  19.     #define I64 "%I64d"
  20. #else
  21.     #define I64 "%lld"
  22. #endif
  23. #define mp make_pair
  24. #define pb push_back
  25. #define F first
  26. #define S second
  27. #define next MyLittleNext
  28. //#define end MyLittleEnd
  29. #define all(x) x.begin(), x.end()
  30. #define fn "floyd_joke"
  31.  
  32. int n;
  33.  
  34. ll dist(ll a, ll b)
  35. {
  36.     if (a == b)
  37.         return 0;
  38.     return (((a * b) % inf) * ((a + b) % inf)) % inf;
  39. }
  40.  
  41. int main()
  42. {
  43.     #ifdef fn
  44.         freopen(fn ".in", "r", stdin);
  45.         freopen(fn ".out", "w", stdout);
  46.     #endif
  47.     scanf("%d", &n);
  48.     ll ans = 0;
  49.     for (int i = 1; i <= n; i++)
  50.         for (int j = 1; j <= n; j++)
  51.             ans = (ans + min(dist(i, j), (dist(1, i) + dist(1, j)) % inf)) % inf;
  52.     printf(I64, ans);
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement