結果
問題 |
No.2078 魔抜けなパープル
|
ユーザー |
![]() |
提出日時 | 2022-09-29 01:03:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 704 bytes |
コンパイル時間 | 292 ms |
コンパイル使用メモリ | 41,672 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-22 17:55:23 |
合計ジャッジ時間 | 844 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 |
ソースコード
/* -*- coding: utf-8 -*- * * 2078.cc: No.2078 魔抜けなパープル - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const long long LINF = 1LL << 62; /* typedef */ typedef long long ll; /* global variables */ /* subroutines */ inline ll mp(int k, int x) { return (ll)k * k + x; } ll check(int a, int x, int c) { int k = a / c, r = a % c; return mp(k, x) * (c - r) + mp(k + 1, x) * r; } /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int x, a; scanf("%d%d", &x, &a); ll minp = LINF; for (int c = 1; c <= a; c++) minp = min(minp, check(a, x, c)); printf("%lld\n", minp); } return 0; }