#include아오 -_-#include using namespace std; void repack(int * target, int * src, int start,int size) { memcpy(target, src + start - size, size); memcpy(src, src + start - size, start - size); memcpy(src, target, size); } int main() { int arr[13], cnt, cases, input, i, movset, temparr[13]; cin >> cases; while (cases--) { for (cnt = 0; cnt < 13; cnt++) { arr[cnt] = 0; } cin >> input; cnt = 1; while (input) { for (i = cnt - 1; i >= 0; i--) { arr[i + 1] = arr[i]; } arr[0] = input; if (cnt > 1) { if (cnt < input) { movset = input % cnt; if (movset == 0) { cnt++; input--; continue; } //repack(temparr, arr, cnt, movset); memcpy(temparr, arr + cnt - movset, movset * sizeof(int)); memcpy(arr + movset, arr, (cnt - movset) * sizeof(int)); memcpy(arr, temparr, movset * sizeof(int)); } else if (cnt > input) { //repack(temparr, arr, cnt, input); movset = input; memcpy(temparr, arr + cnt - movset, movset * sizeof(int)); memcpy(arr + movset, arr, (cnt - movset) * sizeof(int)); memcpy(arr, temparr, movset * sizeof(int)); } } cnt++; input--; } for (i = 0; i < cnt - 1; i++) { cout << arr[i] << " "; } cout << endl; } return 0; }
코딩 너무 오랜만이라 함수 만들었다가 도로 풀고 종이쪼가리에 풀어가면서 했음.
컴파일러 없으니 더럽게 빡시네요.
'Solutions > Dlbo's Solution' 카테고리의 다른 글
PKU 2291. Rotten Ropes. AC get -_-! (0) | 2011.03.14 |
---|---|
PKU 2181. Jumping Cows -_- AC get (2) | 2011.03.06 |
PKU 3176. Cow bowling. AC get -_- (0) | 2010.11.02 |
PKU 2260. Error Correction. AC get -_- (3) | 2010.10.28 |
PKU 3085. Quick Change. AC get -_- (0) | 2010.10.28 |