結果
| 問題 | 
                            No.1803 Remainder of Sum
                             | 
                    
| コンテスト | |
| ユーザー | 
                             bachoppi
                         | 
                    
| 提出日時 | 2022-01-07 22:25:57 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 243 ms / 2,000 ms | 
| コード長 | 804 bytes | 
| コンパイル時間 | 1,103 ms | 
| コンパイル使用メモリ | 114,504 KB | 
| 最終ジャッジ日時 | 2025-01-27 09:36:00 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 8 | 
ソースコード
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int main(){
 int T; cin >> T;
  rep(i, T){
    ll n, m; cin >> n >> m;
    if(n>=m) cout << m/2 << endl;
    else{
      ll ko = min(n-1, m-n-1);
      ll ans = 3*ko + ko*(ko-1)/2;
      ans+=max(0LL, n-(m+1)/2);
      cout << ans << endl;
    }
  }
}
            
            
            
        
            
bachoppi