結果
| 問題 |
No.873 バイナリ、ヤバいなり!w
|
| コンテスト | |
| ユーザー |
tko919
|
| 提出日時 | 2019-08-30 22:49:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,382 bytes |
| コンパイル時間 | 2,090 ms |
| コンパイル使用メモリ | 174,736 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-24 01:41:45 |
| 合計ジャッジ時間 | 3,140 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 WA * 13 |
ソースコード
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end
vector<int> sq;int n,d,rt;
void init(){
rep(i,0,600)rep(j,0,50)rep(k,0,20){
d=n-i*i-j*j-k*k;
if(d<0)continue;
rt=sqrt(d);
if(rt*rt==d){
sq.push_back(i);
sq.push_back(j);
sq.push_back(k);
sq.push_back(rt);
return;
}
}
}
int main(){
scanf("%d",&n); init();
sort(ALL(sq));
string ans;
do
{
string sub; char c='0';
rep(rot,0,4)rep(i,0,sq[rot]){
if(i){
if(c=='0')c='1';
else c='0';
}
sub+=c;
}
if(ans=="")ans=sub;
else chmin(ans,sub);
} while (next_permutation(ALL(sq)));
cout<<ans<<endl;
return 0;
}
tko919