Artwork
Aschool
Study room
Test
Submission Status
Board
English
keyboard_arrow_down
Korean
English
Sign in
Sign up
Sign in
Sign up
Aschool
Study room
Test
Submission Status
Board
Practice room
Mypage
Korean
English
Sign in
1년 전
2020 중등부 20번 체험
Mickey 박민수
mspark
#include<bits/stdc++.h> using namespace std; using pii = pair<int,int>; int rn = 172123, pn = 1, mn = 39186, sz=11; int ran(){pn=(rn*pn)%mn; return pn;} int main() { int arr[sz]; pii brr[sz]; for(int i=0; i<sz; i++) brr[i] = (pii){i, ran()}; sort(brr, brr+sz, [](pii x, pii y){return x.second<y.second;});for(int i=0; i<sz; i++) arr[i]=brr[i].first+1; int crr[sz]; int cnt = 0; for(int i=0; i<sz; i++) crr[i] = i+1; while(1) { int x, y; cin>>x>>y; swap(crr[x-1], crr[y-1]); cnt = 0; for(int i=0; i<sz; i++) {cout<<crr[i]<<" ";cnt += abs(crr[i]-arr[i]);} cout<<'\n'; cout<<"차이의 합은 "<<cnt<<"입니다.\n"<<endl; if(cnt == 0) break; } }
4
Manual