// #include "pch.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; typedef std::pair Pii; typedef std::pair Pll; typedef std::pair Pdd; #define rip(i, n, s) for (int i = (s);i < (int)( n ); i++) #define all(a) a.begin(), a.end() #define MM << " " << template using MaxHeap = std::priority_queue; template using MinHeap = std::priority_queue, std::greater>; template inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } # ifndef ONLINE_JUDGE template void vdeb(std::vector &bb) { for (int i = 0;i < bb.size();i++) { if (i == bb.size() - 1) std::cout << bb[i]; else std::cout << bb[i] << ' '; } std::cout << '\n'; } template void vdeb(std::vector> &bb) { for (int i = 0;i < bb.size();i++) { std::cout << i << ' '; vdeb(bb[i]); } std::cout << '\n'; } # endif using namespace std; ll solve() { ll d, a, b; cin >> d >> a >> b; ll ans = 0; ans += (d-1)*d/2*(b/(d-1)); b %= d-1; ans += (b+1)*b/2; --a; ans -= (d-1)*d/2*(a/(d-1)); a %= d-1; ans -= (a+1)*a/2; return ans; } int main() { int t; cin >> t; vector ans(t); rip(i,t,0) ans[i] = solve(); rip(i,t,0) printf("%lld\n", ans[i]); }