Advertisement
splash365

How many Triangles?

Oct 14th, 2021
728
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.95 KB | None | 0 0
  1. /////how many triangles
  2. #pragma GCC optimize ("Ofast")
  3. #include"bits/stdc++.h"
  4. using namespace std;
  5.  
  6. //#include <ext/pb_ds/assoc_container.hpp>
  7. //#include <ext/pb_ds/tree_policy.hpp>
  8. //using namespace __gnu_pbds;
  9.  
  10. struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
  11. #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
  12. template <typename Arg1>
  13. void __f(const char* name, Arg1&& arg1) {
  14.     cerr << name << " : " << arg1 << endl;
  15. }
  16. template <typename Arg1, typename... Args>
  17. void __f(const char* names, Arg1&& arg1, Args&&... args) {
  18.     const char* comma = strchr(names + 1, ',');
  19.     cerr.write(names, comma - names) << " : " << arg1 << "  ";
  20.     __f(comma + 1, args...);
  21. }
  22.  
  23. #define ll long long
  24. #define pii pair<int,int>
  25. #define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
  26. #define ff first
  27. #define ss second
  28. #define endll '\n'
  29. #define rep(i,n) for(int i=0;i++<n;)
  30. #define scl(i) scanf("%lld",&i)
  31. #define int long long int
  32. #define all(n) n.begin(),n.end()
  33. #define mem(n,i) memset(n,i,sizeof n)
  34. #define em(a) emplace_back(a)
  35. #define pb(a) push_back(a)
  36. #define srep(it,vv) for(auto &it : vv)
  37. #define prep(it,vv) for(auto it : vv)
  38. #define b_s(a,b) binary_search(a.begin(),a.end(),b)
  39. #define l_b(a,b) lower_bound(a.begin(),a.end(),b)
  40. #define u_b(a,b) upper_bound(a.begin(),a.end(),b)
  41. //vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));
  42.  
  43. typedef vector<int> vii;
  44. typedef vector<string> vss;
  45.  
  46. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  47. int my_rand(int l, int r) {
  48.     return uniform_int_distribution<int>(l, r) (rng);
  49. }
  50.  
  51. int call(int n, int x)
  52. {
  53.     return ((n * (n - 1)) >> 1) * x;
  54. }
  55.  
  56. signed main()
  57. {
  58. #ifndef ONLINE_JUDGE
  59.     freopen("input.txt", "r", stdin);
  60.     freopen("output.txt", "w", stdout);
  61. #endif
  62.     int __, _ = 0;
  63.     cin >> __;
  64.     for (; _++ < __;)
  65.     {
  66.         int a, b; cin >> a >> b;
  67.         cout << call(a, b) + call(b, a) << endll;
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement