Algorithm15 BOJ 1300: k번째 수 #include #include using namespace std; long long n, k; long long s, e, mid; long long sum, ans; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> k; s = 1; e = k; while(s n >> k; s = 1; e = k; while(s 2023. 11. 9. Codeup 1430: 기억력 테스트 2 #include using namespace std; int n, m, tmp1, tmp2; bool inp[10001000]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for(int i=0; i> tmp1; inp[tmp1] = true; } cin >> m; for(int i=0; i> tmp2; if(inp[tmp2] == false) cout 2023. 11. 9. BOJ 2512: 예산 #include #include using namespace std; int n, m; int inp[10100]; int sum, s, e, mid; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for(int i=1; i> inp[i]; } sort(inp, inp+n+1); cin >> m; e = inp[n]; while(s 2023. 11. 9. Codeup 3006: 완전 제곱수 찾기 #include #define ll unsigned long long int using namespace std; ll n, a; bool condition(ll x) { if(x*x > a) return true; else return false; } ll binary_search(ll l, ll r) { ll m = (l+r)/2; if(l == r) return (m-1)*(m-1); if(condition(m)) return binary_search(l, m); else return binary_search(m+1, r); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for(int i=0; i.. 2023. 11. 9. 이전 1 2 3 4 다음