結果

問題 No.2078 魔抜けなパープル
ユーザー Nzt3
提出日時 2022-12-22 23:14:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 358 bytes
コンパイル時間 1,910 ms
コンパイル使用メモリ 192,852 KB
最終ジャッジ日時 2025-02-09 18:34:07
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin>>T;
  while(T--){
    int A,X;
    cin>>X>>A;
    long long ans=1e18;
    for(long long i=1;i<=A;i++){
      long long t=A/i,now=X*i;
      now+=(t+1)*(t+1)*(A%i)+t*t*(i-A%i);
      ans=min(ans,now);
    }
    cout<<ans<<'\n';
  }  
}
0