Run ID:122164
提交时间:2025-06-14 16:44:27
#include <iostream> #include <vector> using namespace std; vector<int> findBonePositions() { const int total = 30; const int bones = 15; const int step = 9; vector<int> sequence(total, 0); vector<int> finalPositions; for (int i = 0; i < bones; ++i) { finalPositions.push_back(i); } int currentSize = bones; int currentPos = 0; for (int round = 1; round <= total - bones; ++round) { currentPos = (currentPos - step) % currentSize; if (currentPos < 0) { currentPos += currentSize; } finalPositions.insert(finalPositions.begin() + currentPos, -1); // -1 represents carrot currentSize++; } for (int pos : finalPositions) { if (pos != -1) { sequence[pos] = 1; } } return sequence; } int main() { vector<int> bonePositions = findBonePositions(); cout << "Initial arrangement (0=carrot, 1=bone):" << endl; for (int i = 0; i < 30; ++i) { cout << bonePositions[i] << " "; if ((i + 1) % 10 == 0) cout << endl; } cout << endl; cout << "Bone positions (1-based): "; for (int i = 0; i < 30; ++i) { if (bonePositions[i] == 1) { cout << i + 1 << " "; } } cout << endl; return 0; }