본문 바로가기

전체 글

[C++] 백준 4344번 : 평균은 넘겠지 https://www.acmicpc.net/problem/4344 #include using namespace std;int main() {int n;cin >> n; int **T_c = new int*[n];int n1;for (int i = 0; i > n1;T_c[i] = new int[n1 + 1];T_c[i][0] = n1;for (int j = 1; j > T_c[i][j];}}int sum, cnt;for (int i = 0; i < n; i++) {sum = 0;cnt = 0;for (int j = 1; j 더보기
[C++] 백준 1110번 : 더하기 사이클 https://www.acmicpc.net/problem/1110 #include using namespace std;int main() {int n;cin >> n;int next = n, cnt = 0;do{cnt++;next = next % 10 * 10 + (next / 10 + next % 10) % 10;} while (n != next);cout 더보기
[C++] 백준 1085번 : 직사각형에서 탈출 https://www.acmicpc.net/problem/1085 #include using namespace std;int main(){ int x,y,w,h; cin >> x >> y >> w >> h; int dis[4]; dis[0] = x; dis[1] = h-y; dis[2] = w-x; dis[3] = y; int result = dis[0]; for(int i=0; i dis[i+1]) result = dis[i+1]; } cout 더보기
스레드 블록 아키텍처(Thread Block Architecture) - 그리드 블록 모델 -3 2.6 매트릭스 곱 이전 글에서 살펴본 매트릭스는 12 X 12 크기로 작상서 GPU가 최대 효율을 발휘하지 않는다. 그러나 CUDA 프로그래밍에 익숙해지고 2차원 스레드의 작업 분할에 대하여 알아보는 것이 목적이므로 작은 매트릭스 크기로 진행하는 것이 이해하기 쉽다. 행렬의 곱 M X N = P 는 다음과 같이 계산된다. P( tx, ty) = M(0, ty) X N(tx, 0) + M(1, ty) X N(tx, 1) + M(2, ty) X N(tx, 2) + M(3, ty) X N(tx, 3) + ..... M(11, ty) X N(tx, 11); 위의 수식을 C코드로 구현하게 되면 12회 계산의 for 루프를 가지게 되고 매트릭스에 12 X 12 개의 연산이 있기 때문에 총 연산은 12 X 12 X.. 더보기
[C++] 백준 10817번 : 세 수 https://www.acmicpc.net/problem/10817 #include using namespace std; int main(){ int a,b,c; int tmp; cin >> a >> b >> c; if(a > b) { if(a > c){ if(b>c) tmp = b; else tmp = c; } else { if(a>b) tmp = a; else tmp = b; } } else { if(b > c){ if(c>a) tmp = c; else tmp = a; } else{ if(b>a) tmp = b; else tmp = a; } } cout 더보기
[C++] 백준 2839번 : 설탕 배달 https://www.acmicpc.net/problem/2839 #include using namespace std;int main() {int in_kg, cnt = 0;int kg5, kg3; cin >> in_kg;kg5 = (in_kg - in_kg % 5) / 5;while (kg5 >= 0) {if (((in_kg - kg5 * 5) % 3) == 0) {kg3 = (in_kg - kg5 * 5) / 3;cnt = kg5 + kg3;kg5 = 0;}kg5--;} if (cnt == 0)cout 더보기
[C++] 백준 2741번 : N 찍기 https://www.acmicpc.net/problem/2741 #include using namespace std; int main(){ int n,k=1; cin >> n; while(n>=k){ cout 더보기
[C++] 백준 2292번 : 벌집 https://www.acmicpc.net/problem/2292 #include using namespace std;int main() {int n, k = 1;cin >> n;while (3 * k*k - 3 * k + 1 < n) {k++;}cout 더보기