結果
問題 |
No.853 河原の石
|
ユーザー |
![]() |
提出日時 | 2019-07-26 23:18:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 436 bytes |
コンパイル時間 | 1,065 ms |
コンパイル使用メモリ | 73,816 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-02 09:33:28 |
合計ジャッジ時間 | 1,916 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 4 WA * 53 |
ソースコード
#include <cmath> #include <iostream> #include <algorithm> using namespace std; int main() { int H, W; cin >> H >> W; W = abs(W); if (H == 0 || W == 0) { cout << 0 << endl; } else { int startline = max(W - H, 0) + 1; long long ans = abs(H - W) + 1; for (int i = 0; i < 30; ++i) { int l = max(startline, 1 << i), r = min(W, 2 << i); if (l < r) ans += 1LL * (r - l) * (i + 2); } cout << ans << endl; } return 0; }