42 条题解
-
3
#include <bits/stdc++.h> using namespace std; int n, m, x; string s; char r = '0', p = '1'; bool a[105]; int main() { freopen("three.in", "r", stdin); freopen("three.out", "w", stdout); cin >> n >> m; x = n - m; for (int i = 1; i <= n; i++) { if (i <= 2 && m != 0) { s += p; m--; a[i] = 1; } else if (m != 0 && (a[i - 1] != 1 || a[i - 2] != 1)) { s += p; m--; a[i] = 1; } else if (x != 0 && a[i - 1] == 1 && a[i - 2] == 1) { s += r; x--; a[i] = 0; } else if (m == 0 && x != 0) { s += r; x--; a[i] = 0; } } cout << s; return 0; }
信息
- ID
- 4487
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 8
- 标签
- (无)
- 递交数
- 700
- 已通过
- 105
- 上传者