알고리즘/백준 문제풀이

#include long long fact(int a); int combination(int n, int r); int main() { int T = 0, N = 0, M = 0, val = 0; scanf("%d", &T); for (int i = 0; i < T; i++) { scanf("%d %d", &N,&M); val = combination(M, N); printf("%d\n", val); } return 0; } int combination(int n, int r)// 5,2 { long long val=1; if ((n / 2) < r) r = n - r; for (int i = 0; i < r; i++) { val= val*(n - i); } val = val / fact(r); retu..
#include int main() { int count; int a, b; scanf("%d", &count); for (int i = 0; i < count; i++) { scanf("%d %d", &a, &b); printf("%d \n", a + b); } return 0; }
#include typedef struct Time { int h; //hour int m; //minute } Time; int main() { Time t; scanf("%d %d", &t.h, &t.m); if (t.m >= 45) { t.m -= 45; } else { if (t.h == 0) { t.h = 23; t.m = t.m + 60 - 45; } else { t.h -= 1; t.m = t.m + 60 - 45; } } printf("%d %d", t.h, t.m); return 0; }
#include typedef struct Coordinate { int x; // Coordinate of x int y; // Coordinate of y int Quad; //Quadrant(사분면) ex)1,2,3,4 } Coord; int main() { Coord c1; scanf("%d %d", &c1.x, &c1.y); //case1 x>0 if (c1.x > 0) { if (c1.y > 0) printf("1 \n"); else if (c1.y < 0) printf("4 \n"); else printf("On the x-axis \n"); } //case2 x 0) printf("2 \n"); else if (c1.y < 0) printf("3 \n"); else printf("On th..
#include int main() { int a; scanf("%d", &a); if (a % 4 == 0 && a % 100 != 0) printf("1 \n"); else if (a % 400 == 0) printf("1 \n"); else printf("0 \n"); return 0; }
#include int main() { int A; scanf("%d", &A); if (A >= 90 && A = 80 && A = 70 && A = 60 && A
ya_ya
'알고리즘/백준 문제풀이' 카테고리의 글 목록 (4 Page)