結果
問題 | No.2746 Bicolor Pyramid |
ユーザー | hiikunZ |
提出日時 | 2024-04-20 20:25:33 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,591 bytes |
コンパイル時間 | 2,028 ms |
コンパイル使用メモリ | 203,628 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 18:30:36 |
合計ジャッジ時間 | 3,115 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
ソースコード
#include <bits/stdc++.h> using namespace std; //#include<atcoder/all> //using namespace atcoder; using ll = long long int; using ull = unsigned long long int; using ld = long double; constexpr ll MAX = 2000000000000000000; constexpr ld PI = 3.14159265358979; constexpr ll MOD = 0;//2024948111; ld dotorad(ld K){ return PI * K / 180.0; } ld radtodo(ld K){ return K * 180.0 / PI; } mt19937 mt; void randinit(){ srand((unsigned)time(NULL));mt = mt19937(rand()); } int main(){ ll R,B; cin >> R >> B; vector<ll> muri = {2,3,6,7,8,11,12,15,18,19,22,23,24,27,28,31,32,33,43,44,47,48,60,67,72,76,92,96,108,112,128,MAX}; while(1){ ll p = *lower_bound(muri.begin(),muri.end(),R); if(p != R) break; R--; } while(1){ ll p = *lower_bound(muri.begin(),muri.end(),B); if(p != B) break; B--; } if(R + B < 506){ for(ll n = 12;n >= 1;n--){ for(ll bit = 0;bit < (1LL << n);bit++){ ll a = 0,b = 0; for(ll i = 0;i < n;i++){ if(bit & (1LL << i)){ a += (i + 1) * (i + 1); } else{ b += (i + 1) * (i + 1); } } if(a <= R && b <= B){ cout << n << endl; return 0; } } } } ll a = 0; for(ll i = 1;i <= 1817121;i++){ if(a + i * i > R + B){ cout << i - 1 << endl; return 0; } a += i * i; } }