結果

問題 No.2078 魔抜けなパープル
ユーザー keisuke6keisuke6
提出日時 2022-09-25 21:19:23
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 406 bytes
コンパイル時間 2,176 ms
コンパイル使用メモリ 198,784 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 01:58:07
合計ジャッジ時間 2,648 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 16 ms
4,380 KB
testcase_02 AC 12 ms
4,376 KB
testcase_03 AC 14 ms
4,380 KB
testcase_04 AC 11 ms
4,380 KB
testcase_05 AC 11 ms
4,376 KB
testcase_06 AC 24 ms
4,376 KB
testcase_07 AC 12 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int T;
  cin>>T;
  for(int i=0;i<T;i++){
      int A,X;
      cin>>A>>X;
      swap(A,X);
      int ans = 1e18;
      for(int j=1;j<=A;j++){
          int now = j*X;
          int a = A/j;
          int b = A%j;
          now += a*a*(j-b)+(a+1)*(a+1)*b;
          ans = min(ans,now);
      }
      cout<<ans<<endl;
  }
}
0