解题思路:
注意事项:
参考代码:
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <vector> using namespace std; vector<int> arr; int solve() { int index = 0; while (arr.size() > 1) { int newIndex = (index + 2) % arr.size(); arr.erase(arr.begin() + newIndex); index = newIndex; } return arr[0]; } int main() { int n = 0; cin >> n; for (int i = 1; i <= n; i++) arr.push_back(i); cout << solve() << endl; return 0; }
0.0分
0 人评分
小九九 (C语言代码)浏览:817 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:689 |
C二级辅导-计负均正 (C语言代码)浏览:647 |
时间转换 (Java代码)浏览:572 |
C语言程序设计教程(第三版)课后习题8.9 (Java代码)浏览:1325 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:510 |
C语言考试练习题_一元二次方程 (C语言代码)浏览:575 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:682 |
C语言程序设计教程(第三版)课后习题9.10 (C语言代码)浏览:819 |
模拟计算器 (C++代码)浏览:800 |