結果
問題 |
No.853 河原の石
|
ユーザー |
![]() |
提出日時 | 2019-07-26 22:58:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 773 bytes |
コンパイル時間 | 1,352 ms |
コンパイル使用メモリ | 97,796 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-02 08:57:35 |
合計ジャッジ時間 | 3,327 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 4 WA * 53 |
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair<ll, ll> P; int main() { ll h, w; cin>>h>>w; if(h==0 || w==0){ cout<<0<<endl; return 0; } w=abs(w); ll ans=h*w; for(ll k=(w+h-1)/h; k<=(w+h-1)/h+1000000; k++){ ll x=w/k; ll s=((x+1)*(x+1)*(w%k)+x*x+(k-w%k)-w)/2+h*k; ans=min(ans, s); } cout<<ans<<endl; return 0; }