#include //#include using namespace std; //using namespace atcoder; //g++ hoge.cpp (-std=c++17) -I . で実行 #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") typedef long long ll; typedef pair prl; typedef vector vcl; typedef map mapl; typedef unordered_map umap; #define pb push_back #define all(v) v.begin(), v.end() #define rep(i,a,b) for(ll i=a;i<=b;i++) #define repi(i,a,b) for(int i=a;i<=b;i++) #define repr(i,a,b) for(ll i=a;i>=b;i--) #define reps(i,v) for(ll i=0;i void chmin(T &a, const T &b) { a = min(a, b); } template void chmax(T &a, const T &b) { a = max(a, b); } const ll mod = 1e9+7; //Prime_Factorization vector prime_fact(ll n){ vector p; ll nc = n; for(ll i = 2; i * i <= n; i++){ if(nc % i !=0) continue; ll c = 0; while(nc % i == 0) c++, nc /= i; p.push_back({i, c}); } if(nc > 1) p.push_back({nc, 1}); return p; } int main() { // your code goes here ll t; cin >> t; rep(ts,1,t){ ll d,a,b,p,q,r,s,ans; cin >> d >> a >> b; d--; p=a/d; q=a%d; r=b/d; s=b%d; if(p==r){ ans = (q+s)*(s-q+1)/2; if(q==0) ans+=d; } else { ans=(0+s)*(s-0+1)/2+(q+(d-1))*((d-1)-q+1)/2+(r-p-1)*(d-1)*(d-1+1)/2; ans+=d*(r-p); if(s==0) ans+=d; } cout << ans << endl; } return 0; }