전체 글

    코드업 6095 [기초-리스트] 바둑판에 흰 돌 놓기

    n = int(input()) game = [[0 for _ in range(19)] for _ in range(19)] # 19x19 배열을 0으로 채우기 for i in range(n): a,b = map(int, input().split()) game[a-1][b-1] = 1 for i in range(19): for j in range(19): print(game[i][j], end = ' ') print( ) 처음 파이썬을 공부할 때 알고리즘도 같이 해놓았으면 좋았을것을..

    코드업 6092 [기초-리스트] 이상한 출석 번호 부르기1

    n = int(input()) a = input().split() for i in range(n): # a에 split으로 입력된 값들을ㅌ a[i] = int(a[i]) # a[0]~a[n-1]에 할당 d = [] for i in range(24): # 리스트 d에 24개까지 0으로 할당 d.append(0) for i in range(n): # 불려진 숫자를 d의 a번의 학생이 불릴때마다 카운트한다. d[a[i]] += 1 for i in range(1,24): print(d[i], end=' ') 역순으로 출력하기 코드 퀄리티 보소 n = int(input()) k = list(map(int, input().split())) for i in range(n-1,-1,-1): print(k[i], end..

    C++ 2442 별찍기 5

    #include using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 1; i

    C++ 10984 내학점을 구해줘

    #include #include using namespace std; int main() { ios_base::sync_with_stdio(); cin.tie(); cout.tie(); int n; cin >> n; while (n--) { int num; cin >> num; vectorgrade(num); int sum = 0; float avg = 0; for (int i = 0; i > grade[i].first >> grade[i].second; for (int i = 0; i < num; i++) { sum += grade[i].first; avg += grade[i].first * grade[i].second; } cout

    turtlebot3 시뮬레이션

    시뮬레이션 환경에서 터틀봇을 운영해보겠다. $ cd ~/catkin_ws/src/ $ git clone -b kinetic-devel https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git $ cd ~/catkin_ws && catkin_make 터틀봇 시뮬레이션 깃 클론(어제 해놓음) $ roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch empty world에서 터틀봇 불러내기 마찬가지로 roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch로 조작한다. $ roslaunch turtlebot3_gazebo turtlebot3_world.launch $ r..

    TurtleBot3 사용하기

    아으.. 어렵다. 블로그를 보고 터틀봇을 gazebo환경에서 구현해보았다. http://turtlebot3.robotis.com ROBOTIS e-Manual emanual.robotis.com cd ~/catkin_ws/src/ git clone https://github.com/ROBOTIS-GIT/turtlebot3.git git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git cd ~/catkin_ws && catkin_make 터틀봇과 관련된 깃허브를 클론한다. export TURTLEBOT3_MODEL=burger 매번 ..

    ROS service 프로그래밍

    아래의 블로그를 보고 ROS를 복기하고 있다. catkin_create_pkg ros_tutorials_service roscpp std_msgs message_generation package.xml파일 수정 ros_tutorials_service 0.0.1 request/response service Apache License 2.0 someone catkin message_generation roscpp std_msgs roscpp std_msgs roscpp std_msgs message_runtime CMakeLists.txt 수정 cmake_minimum_required(VERSION 3.0.2) project(ros_tutorials_service) find_package(catkin REQ..

    C++ 5635 생일

    #include #include ; #include ; #include using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >>n; vectorname(n); for (int i = 0; i > name[i].second.second >> name[i].second.first >> name[i].first.second>>name[i].first.first; } sort(name.begin(), name.end()); cout

    C++11098 첼시를 도와줘

    #include #include ; #include ; using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; while (n--) { int t; cin >> t; int max = 0; vector c(t); string maxName; for (int i = 0; i > c[i].first >> c[i].second; if (max < c[i].first) { max = c[i].first; maxName = c[i].second; } } cout

    C++ 1977 완전제곱수

    #include #include using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int m, n; cin >> m >> n; int arr[10000] = { 0 }; int sum = 0; int min = 10000; for (int i = 1; i < n; i++) { arr[i] = i * i; } for (int i = 1; i

    C++ 1541 잃어버린 괄호

    #include #include using namespace std; int main() { ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); string str; string tmp = ""; int res = 0; bool minus = false;//빼기 확인용 cin >> str; for (int i = 0; i

    C++ 11399 ATM

    #include #include #include using namespace std; int main() { ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); int n; cin >> n; vectorbank(n); for (int i = 0; i > bank[i]; sort(bank.begin(), bank.end()); int time = 0; for (int i = 1; i

    C++ 1931 회의실 배정

    문제를 이해하는것도 한참걸렸다. #include #include #include using namespace std; int main() { ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); int n; cin >> n; vectortime(n); int savetime = 0; int cnt = 0; for (int i = 0; i > time[i].second >> time[i].first; sort(time.begin(), time.end()); for (int i = 0; i < n; i++) { if (savetime

    C++ 11047 동전0 (그리디알고리즘)

    #include #include #include using namespace std; int main() { int n, k; cin >> n >> k; vectorcoin(n); int cnt = 0; for (int i = 0; i > coin[i]; } sort(coin.begin(), coin.end(), greater()); for (int i = 0; i = 0) { cnt++; k -= coin[i]; } } cout

    C++ 11650 좌표 정렬하기

    #include #include #include using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vectorarr(n, vector(2, 0)); for (int i = 0; i > arr[i][0]; cin >> arr[i][1]; } sort(arr.begin(), arr.end()); for (int i = 0; i < arr.size(); i++) { cout

    C++ 1427 소트 인사이드

    #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string strNum; cin >> strNum; sort(strNum.begin(), strNum.end(), greater()); cout

    C++ 2231 분해합

    #include using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int min = n; for (int i = 0; i n; for (int i = 1; i

    C++ 2798 블랙잭

    #include using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; int* arr = new int[n]; int max=0; for (int i = 0;i > arr[i]; } for (int i = 0;i < n;i++) { for (int j = i+1; j < n;j++) { for (int k = j+1; k < n; k++) { if (i != j || j != k || k != i) { int sum = arr[i] + arr[j] + arr[k]; if (sum

    C++ 4153 직각삼각형

    #include using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int x, y, z; while (1) { cin >> x >> y >> z; int temp = 0; if (x == 0 || y == 0 || z == 0) break; if (x > y) { temp = x; x = y; y = temp; } if (y > z) { temp = y; y = z; z = temp; } if (z * z == x * x + y * y) { cout

    C++1085 직사각형에서 탈출

    #include using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int x, y, w, h; cin >> x >> y >> w >> h; int xmin = 0; int ymin = 0; int totalmin = 0; (x) > (w - x) ? xmin = w - x : xmin = x; (y) > (h - y) ? ymin = h - y : ymin = y; xmin > ymin ? totalmin = ymin : totalmin = xmin; cout

    C++ 9020 골드바흐의 추측

    #include #include using namespace std; bool isPrime(int i) {//소수면 true를 반환함. int rt; rt = sqrt(i); if (rt == 1 && i != 1) return true; if (i % 2) { for (int j = 2; j > t; while (t--) { int n; cin >> n; for (int i = n / 2; i >= 2;i--) { if (isPrime(i) && isPrime(n - i)) { cout

    C++ 4948 베르트랑 공준

    #include using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int cnt = 0; int res = 0; for (int i = n+1; i

    C++ 11653 소인수분해

    #include using namespace std; int main() { //소인수분해 int n; cin >> n; while (n!=1) { for (int i = 2;i

    C++ 2581 소수

    #include using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int m, n; cin >>m >> n; int cnt = 0; int max=0; int min = -1; for (int i = m;i

    C++ 피보나치 수열

    #include using namespace std; int fib(int num) { if (num == 0) return 0; else if (num == 1) return 1; else return fib(num - 1) + fib(num - 2); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; cout

    C++ 2839 설탕배달

    #include using namespace std; int main() { int n; cin >> n; int head = n / 5; int mod, res; while (head >= 0) { mod = 0; res = 0; if (head > 0) { mod = n - 5 * head; res = head; } else mod = n; res += mod / 3; mod = mod % 3; if (mod == 0) { cout

    C++ 2292 벌집

    #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int layer = 1; int room = 1; int roomN; cin >> roomN; while (roomN > room) { layer++; room += 6 * (layer - 1); } cout

    C++ 2908 상수

    #include #include #include using namespace std; int main() { string a, b; cin >> a >> b; reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); cout b ? a : b); } 아으.. reverse로 푸는 걸 까먹어서 두 번째 풀어도 헤맸다. 외우자.

    C++ 1157 단어공부

    #include #include #include using namespace std; int main() { string word; cin >> word; int point; int max = 0; int cnt = 0; int arr[26] = { 0 }; transform(word.begin(), word.end(), word.begin(), (int(*)(int))toupper); for (int i = 0; i max) { max = arr[i]; cnt = 0; point = i; } if (max == arr[i]) cnt++; } i..

    C++ 1152 단어의 개수

    #include #include using namespace std; int main() { string s; getline(cin, s); int cnt = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == ' ') { cnt++; } } if (s[0] == ' ') { cnt--; } if (s[s.size()-1] == ' ') { cnt--; } cout