結果

問題 No.2078 魔抜けなパープル
ユーザー momoyuumomoyuu
提出日時 2023-05-20 01:40:12
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 2,714 ms
コンパイル使用メモリ 242,332 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-08-23 04:26:10
合計ジャッジ時間 3,639 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 16 ms
4,376 KB
testcase_02 AC 12 ms
4,376 KB
testcase_03 AC 14 ms
4,376 KB
testcase_04 AC 11 ms
4,376 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;
using ll = long long;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t ;
    cin>>t;
    while(t--){
        ll x,a;
        cin>>x>>a;
        ll ans = 1e15;
        for(int i = 1;i<=a;i++){
            ll now = x * i;
            ll need = a / i;
            ll tmp = a % i;
            now += need * need * (i-tmp);
            now += (need+1)*(need+1) * tmp;
            ans = min(ans,now);
        }
        cout<<ans<<endl;

    }
}



0