본문 바로가기

반응형

알고리즘

(136)
2750번 수 정렬하기 12345678910111213141516171819202122232425262728293031#include #include #include using namespace std; int main() { int n; scanf("%d", &n); vector v(n); for(int i = 0; i
6064번 카잉 달력 123456789101112131415161718192021222324252627282930#include using namespace std; int main() { int t, M, N, x, y; scanf("%d", &t); while(t--) { scanf("%d %d %d %d", &M, &N, &x, &y); int tempX = 0, tempY = 0; int count = 1; bool isExist = true; while(!(tempX * M + x == tempY * N + y)) { if(tempX * M + x > M * N || tempY * N + y > M * N) { isExist = false; break; } if(tempX * M + x > tempY * N + y)..
Equalize the Array 12345678910111213141516171819202122232425262728// Complete the equalizeArray function below.int equalizeArray(vector arr) { int maxCount = 1; int maxNum = arr[0]; int tempCount = 1; int tempMax = arr[0]; sort(arr.begin(), arr.end()); for(int i = 0; i = maxCount) { maxNum = tempMax; maxCount = tempCount; } } else { tempCount = 1; tempMax = arr[i + 1]; } } return arr.size() - maxCount; } Colored b..
ACM ICPC Team 123456789101112131415161718192021222324252627282930// Complete the acmTeam function below.vector acmTeam(vector topic) { int maxCount = 0, maxTeams = 0; for(int i = 0; i
1475번 방 번호 12345678910111213141516171819202122232425262728293031323334353637383940414243444546#include using namespace std; int numbers[10] = { 0,}; int main(){ int n; scanf("%d", &n); if (n == 0) { cout
2775번 부녀회장이 될테야 1234567891011121314151617181920212223242526272829303132333435#include using namespace std; int apart[15][15]; void Init(){ for (int i = 0; i k >> n; cout
10250번 ACM 호텔 1234567891011121314151617181920212223#include using namespace std; int main(){ int T, H, W, N; cin >> T; while(T--) { cin >> H >> W >> N; int height = N % H; int floor; if(N % H != 0) floor = N / H + 1; else floor = N / H; if(height == 0) height = H; cout
1193번 분수찾기 123456789101112131415161718192021222324252627#include using namespace std; int main(){ int n; cin >> n; int sum = 0; int num; for (int i = 1; i = n) break; else { sum += i; num = i; } } if (num % 2 == 0) cout