結果
問題 |
No.1372 Median of Submasks
|
ユーザー |
|
提出日時 | 2021-02-05 23:19:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,770 bytes |
コンパイル時間 | 1,830 ms |
コンパイル使用メモリ | 176,180 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 14:31:32 |
合計ジャッジ時間 | 2,751 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 WA * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for (int i = 0; i < (n); ++i) template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;} template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;} using ll = long long; using P = pair<int,int>; using Pl = pair<long long,long long>; using veci = vector<int>; using vecl = vector<long long>; using vecveci = vector<vector<int>>; using vecvecl = vector<vector<long long>>; const int MOD = 1000000007; const double pi = acos(-1); ll gcd(ll a, ll b) {if(b == 0) return a; else return gcd(b,a%b);} ll lcm(ll a, ll b) {return a*b/gcd(a,b);} string d(ll n) { string ans = ""; REP(i,60) { ans += n%2 + '0'; n /= 2; } return ans; } ll f(string S) { ll ans = 0; ll q = 1; REP(i,S.size()) { if(S[i] == '1') ans += q; q *= 2; } return ans; } ll pow(int a, int n) { ll ans = 1; REP(i,n) ans *= a; return ans; } int main() { ll N; cin >> N; if(N == 1) { cout << 1 << endl; return 0; } string S = d(N); //cout << S << endl; vector<string> T(4); ll ans = 0; T[0] = S.substr(0,15); T[1] = S.substr(15,30); T[2] = S.substr(30,45); T[3] = S.substr(45,60); REP(i,4) { vecl res; ll s; if(i == 0) s = 1; else s = 0; for(ll x = s; x < (1LL<<15); x++) { //if(x <= f(T[i])) cout << (x & f(T[i])) << endl; if((x & f(T[i])) == x) { res.push_back(x); } } sort(res.begin(),res.end()); if(res.size() > 0) ans += res[res.size()/2] * pow(2LL,15LL*i); } cout << ans << endl; return 0; }