ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#202112 | #2784. 01串 | snow_trace | 100 | 515ms | 3396kb | C++11 | 696b | 2024-02-12 09:01:07 | 2024-02-12 18:48:59 |
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
unordered_map<int,int>dp;
int c = 0,tot = 0;
vector<int>p,pp;
inline void dfs(int x){
if(!x)return;
int pos = upper_bound(p.begin(),p.end(),x)-p.begin()-1;
for(int i = 0;i<pos+1;i++)cout<<c;tot+=pos+1;c^=1;dfs(x-p[pos]);
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
for(int i = 1;i<=100000;i++)p.push_back(i*(i-1));
for(int i = 1;i<=100000;i++)pp.push_back(i*(i-1)/2);
int t;cin>>t;while(t--){
int n;cin>>n;
int p = lower_bound(pp.begin(),pp.end(),n)-pp.begin();
int s = 2*(pp[p]-n);tot = 0;
dfs(s);assert(tot<=p+1);
while(tot!=p+1)tot++,cout<<c,c^=1;cout<<endl;
}
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 8
Accepted
Test #1:
score: 8
Accepted
time: 2ms
memory: 3396kb
input:
500 13 7 6 20 1 18 17 19 9 15 10 12 9 8 11 15 3 14 7 9 7 17 16 19 18 7 11 14 6 5 17 3 11 7 2 20 7 7 ...
output:
001101 00010 1010 1101010 10 1110101 0001101 0011010 11010 101010 10101 000101 00101 00110 111001 01...
result:
points 1.0 Accepted
Subtask #2:
score: 21
Accepted
Test #2:
score: 21
Accepted
time: 4ms
memory: 3396kb
input:
500 933 647 306 780 621 898 757 879 89 95 790 72 469 828 171 515 623 934 687 589 147 417 816 939 758...
output:
00000111010101010101010101010101010101010101 0000001110010101010101010101010101010 11111100011010101...
result:
points 1.0 Accepted
Subtask #3:
score: 23
Accepted
Test #3:
score: 23
Accepted
time: 5ms
memory: 3392kb
input:
500 84933 1647 40306 72780 90621 15898 73757 86879 66089 93095 5790 43072 69469 44828 60171 14515 68...
output:
0000000000000000011110001010101010101010101010101010101010101010101010101010101010101010101010101010...
result:
points 1.0 Accepted
Subtask #4:
score: 48
Accepted
Test #4:
score: 48
Accepted
time: 504ms
memory: 3392kb
input:
500 253484933 463401647 466040306 780172780 189090621 382815898 292073757 119686879 18566089 2984930...
output:
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 Accepted
Extra Test:
score: 0
Extra Test Passed