본문 바로가기

Programming/BaekJoon

[C++] 백준 1075번 : 나누기 https://www.acmicpc.net/problem/1075 #include using namespace std;int main() {int n, f;cin >> n >> f;n = n - n % 100;for (int i = n; ; i++) {if (i % f == 0){if(i%100 더보기
[C++] 백준 4948번 : 베르트랑 공준 https://www.acmicpc.net/problem/4948 #include #include using namespace std;int main() {cin.tie(NULL);ios::sync_with_stdio(false); int ary[246913] = {0,};int flag = 0;ary[0]=0;ary[1]=0; for (int i = 2; i n;if (n == 0)break; int cnt = 0; for (int i = n + 1; i 더보기
[C++] 백준 2309번 : 일곱 난쟁이 https://www.acmicpc.net/problem/2309 #include #include using namespace std; int main() {cin.tie(NULL);ios::sync_with_stdio(false);int ary[9];int n,sum = 0;for (int i = 0; i > ary[i];sum += ary[i];} int sum2 = sum;for (int i = 0; i < 8; i++){sum2 = sum;sum2 -= ary[i];for (int j = i + 1; j < 9; j++){if ((sum2 - ary[j]) == 100){ary[i] = -1;ary[j] = -1;goto outside;}}}outside: sort(ar.. 더보기
[C++] 백준 1057번 : 토너먼트 https://www.acmicpc.net/problem/1057 #include #include using namespace std; int main() { int n;int m1, m2;cin >> n >> m1 >> m2; n--;m1--;m2--; int tmp = 0;while (1) {if (n >= 2){n /= 2;tmp++;}elsebreak;} int round = tmp + 1;int result = 0, flag = 0;while (flag != 1) {(m1 / (int)pow(2, tmp)) == (m2 / (int)pow(2, tmp)) ? result++ : flag = 1;tmp--;}round -= result; cout 더보기
[C++] 백준 1076번 : 저항 https://www.acmicpc.net/problem/1076 #include #include #include using namespace std; long long detector(string a); int main() {string str1;string str2;string str3;cin >> str1;cin >> str2;cin >> str3;if (detector(str1) != -1 && detector(str2) != -1 && detector(str3) != -1){long long n = (detector(str1) * 10 + detector(str2))*pow(10, detector(str3));cout 더보기
[C++] 백준 1037번 : 약수 https://www.acmicpc.net/problem/1037 #include #include #include using namespace std; int main() {int tc,tmp;vector n;cin >> tc; for (int i = 0; i > tmp;n.push_back(tmp);}sort(n.begin(), n.end());cout 더보기
[C++] 백준 1977번 : 완전제곱수 https://www.acmicpc.net/problem/1977 #include #include using namespace std; int main() { int n1, n2;cin >> n1 >> n2;////int i = sqrt(n1);//int tmp = sqrt(n1);//tmp *= tmp;////tmp = n1 ? i++ : 0; int flag = 0, sum =0,min=0; for (int i = n1; i 더보기
[C++] 백준 2010번 : 플러그 https://www.acmicpc.net/problem/2010 #include using namespace std; int main() {int tc;cin >> tc;int n,cnt =0;for (int i = 0; i > n;cnt += n - 1;}cin >> n;cnt += n; cout 더보기