
1947번 [선물 전달]완전 순열: 일렬로 배열한 대상들의 위치를 재조정했을 때, 모든 대상이 자기 위치에 있지 않도록 하는 배열 방법 점화식: D[n] = (n-1)(D[n-1] + D[n-2])ll dp[1000001];int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n; cin >> n; dp[1] = 0; dp[2] = 1; for (ll i = 3; i 13398번 [연속합 2]수가 하나 제거되면 2부분으로 나뉜다. ㅡ> 2개의 dp배열 사용int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector v; int ..