본문 바로가기

백준4

백준 1296번- 팀 이름 정하기 #include using namespace std; int num; string green, teamName; vector test,team; vector prob; struct CompareTeams{ bool operator()(const pair& a, const pair& b){ if(a.first != b.first){ return a.first b.second; // team 내림차순 정렬 } }; int main(){ cin >> green >> num; test.push_back(green); for(int i=0; i> teamName; team.push_back(teamName); test.push_b.. 2023. 8. 15.
백준 1292번 - 쉽게 푸는 문제 https://www.acmicpc.net/problem/1292 1292번: 쉽게 푸는 문제 첫째 줄에 구간의 시작과 끝을 나타내는 정수 A, B(1 ≤ A ≤ B ≤ 1,000)가 주어진다. 즉, 수열에서 A번째 숫자부터 B번째 숫자까지 합을 구하면 된다. www.acmicpc.net 인덱스와 그 인덱스에 해당하는 배열의 값을 더한다. 그 값이 다음 숫자가 들어갈 자리이다. #include using namespace std; int a,b, sum; int num[1003]; int main(){ cin >> a >> b; //1. 넣기 int std=0; while(std 2023. 8. 14.
백준 10988번 - 팰린드롬인지 확인하기 https://www.acmicpc.net/problem/10988 10988번: 팰린드롬인지 확인하기 첫째 줄에 단어가 주어진다. 단어의 길이는 1보다 크거나 같고, 100보다 작거나 같으며, 알파벳 소문자로만 이루어져 있다. www.acmicpc.net #include using namespace std; string str; int ret=1; int main(){ cin >> str; for(int i=0; i s; tmp = s; reverse(tmp.begin(), tmp.end()); if(tmp == s) cout 2023. 8. 14.
백준 1173번-운동 처음 풀이- 맞음(근데 조건식이 좀 복잡..) #include using namespace std; int N, m, M, T, R, exeCnt=0, totalTime=0, x; int main(){ cin >> N >> m >> M >> T >> R; x = m; //초기 x if(x+T>M && x-R=m x+T >=M일 때, x-R=m x+T N >> m >> M >> T >> R; x = m; //초기 x if(x+T>M && x-R 2023. 7. 31.