2 条题解
-
-6刘臻昊 LV 6 @ 2022-11-24 19:12:41
#include <stdio.h> #include <iostream> #include <string.h> using namespace std; int a[1010]; int main() { int n; cin >> n; int sum = n; int cnt = 0; int f = 1; for(int i = 1 ; i >= 1 && i <= n ; i += f) { if(a[i] == 0) { cnt++; if(sum == 2) { cout << i << endl; break; } if(cnt%3 == 0) { sum--; a[i] = 1; } } if( (i == 1 && f == -1) || (i == n && f == 1) ) { cnt = 0; if(a[i]==0) cnt = 1; f = -f; } } }
-
-142022-3-13 21:01:19@
#include <stdio.h> #include <iostream> #include <string.h> using namespace std; int a[1010]; int main() { int n; cin >> n; int sum = n; int cnt = 0; int f = 1; for(int i = 1 ; i >= 1 && i <= n ; i += f) { if(a[i] == 0) { cnt++; if(sum == 2) { cout << i << endl; break; } if(cnt%3 == 0) { sum--; a[i] = 1; } } if( (i == 1 && f == -1) || (i == n && f == 1) ) { cnt = 0; if(a[i]==0) cnt = 1; f = -f; } } }
- 1
信息
- ID
- 1000
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 4
- 标签
- 递交数
- 496
- 已通过
- 210
- 上传者