Baekjoon 2839.ŠEĆER c++ [Silver IV]
·
Baekjoon/Silver
#include #include #include #include #include using namespace std;int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int N; cin >> N; int packages=0; while (N >= 0) { if (N % 5 == 0) { packages += N / 5; cout
Baekjoon 1920.수 찾기 c++ [Silver V]
·
Baekjoon/Silver
Unordered_set을 사용해서 중복검사#include #include #include #include #include using namespace std;int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int N, M; int count; unordered_set numbers; cin >> N; for (int i = 0; i > num; numbers.insert(num); } cin >> M; for (int i = 0; i > check; if (numbers.count(check) > 0) cout
Baekjoon 11651. 좌표 정렬하기 c++ [Silver V]
·
Baekjoon/Silver
sort부분에 Lambda함수를 사용sort(1, 2, 3) 3번에서 []로 시작하는 부분이 Lambda를 사용한 부분이다.#include #include #include using namespace std;int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int N; vector> coordinate; cin >> N; for (int i = 0; i > x >> y; coordinate.push_back({x, y}); } sort(coordinate.begin(), coordinate.end(), [](const pair &a, const pair &..
Baekjoon 1676. 팩토리얼 0의 개수 c++ [Silver V]
·
Baekjoon/Silver
삽질해서 시간초과했다가 깨달아서 만든 코드10! = 3628800뒷자리 0은 10의 여부에 따라 결정 => 2x5 => 2는 너무 많기에 5로 나눠지는 애들을 세주면 됨#include using namespace std;int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int N; cin >> N; int count = 0; for (int i = 5; i
Baekjoon 28702. FizzBuzz c++ [Bronze I]
·
Baekjoon/Bronze
#include #include using namespace std;string getFizzBuzz(int num) { if (num % 15 == 0) return "FizzBuzz"; else if (num % 3 == 0) return "Fizz"; else if (num % 5 == 0) return "Buzz"; else return to_string(num);}int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int temp,idx; for(int i=0;i> fizzbuzz; if(fizzbuzz!="FizzBuzz" && fizzb..
Baekjoon 10989. 수 정렬하기 3 c++ [Bronze I]
·
Baekjoon/Bronze
메모리 초과#include #include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N,num; cin >> N; vector numbers; for(int i=0;i> num; numbers.push_back(num); } sort(numbers.begin(),numbers.end()); for(int i=0;i 카운팅 정렬#include using namespace std;const int MAX_VALUE = 10000;int main() { ios::sync_with_stdio(false); cin.ti..