๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ“šAlgorithm ------------/๋ฐฑ์ค€

(4)
๋ฐฑ์ค€ 11720๋ฒˆ: ์ˆซ์ž์˜ ํ•ฉ(Python) https://www.acmicpc.net/problem/11720 11720๋ฒˆ: ์ˆซ์ž์˜ ํ•ฉ ์ฒซ์งธ ์ค„์— ์ˆซ์ž์˜ ๊ฐœ์ˆ˜ N (1 ≤ N ≤ 100)์ด ์ฃผ์–ด์ง„๋‹ค. ๋‘˜์งธ ์ค„์— ์ˆซ์ž N๊ฐœ๊ฐ€ ๊ณต๋ฐฑ์—†์ด ์ฃผ์–ด์ง„๋‹ค. www.acmicpc.net cnt = input() cntInt = int(cnt) if cntInt 100: exit(1) numList = input() ret = 0 for i in numList: ret += int(i) print(ret) ๋ฌธ์ œ์—๋„ ๋‚˜์™€์žˆ๋“ฏ์ด ์–ธ์–ด๋ณ„๋กœ ์ˆซ์žํ˜• ํฌ๊ธฐ ๋‹ค๋ฃจ๋Š”๊ฒŒ ๋‹ค๋ฅด๋‹ˆ๊นŒ int ๋ฒ”์œ„ ๋„˜์–ด๊ฐˆ ๋•Œ๋งŒ ์ž˜ ๋‹ค๋ฃจ๋ฉด ๋ ๋“ฏ ์ž๊พธ if๋ฌธ์— ์กฐ๊ฑด ์“ธ ๋•Œ || ๋‚˜ && ์“ฐ๊ฒŒ ๋œ๋‹ค.. ์Šต๊ด€์ด ๋ฌด์„ญ๋‹ค
๋ฐฑ์ค€ 11654๋ฒˆ: ์•„์Šคํ‚ค ์ฝ”๋“œ (Python) a = input() print(ord(a)) * ๋ฌธ์ž์—ด → ์•„์Šคํ‚ค ์ฝ”๋“œ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜ ord(๋ฌธ์ž์—ด) * ์ˆซ์ž → ์•„์Šคํ‚ค ์ฝ”๋“œ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜ chr(์ˆซ์ž) C++๋กœ ํ’€๋ผ๋‹ค๊ฐ€ ์•„... ๋ณ€ํ™˜ํ•˜๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ญ์žˆ์ง€ ํ•˜๋‹ค๊ฐ€ ๊ทธ๋ƒฅ ํŒŒ์ด์ฌ์œผ๋กœ ํ–ˆ๋Š”๋ฐ ๊ฐ€๋” ํŒŒ์ด์ฌ ์“ฐ๋ฉด ํ˜„ํƒ€๊ฐ€ ์˜จ๋‹ค C++๋กœ ๊ฐœ๋ฐœํ•˜๋‹ค๊ฐ€ ๋‚ด๊ฐ€ ์™œ ์ด๊ฑธ ์ด๋ฆฌ ํž˜๋“ค๊ฒŒ..? Cํ•˜๋‹ค๊ฐ€ ๋‚ด๊ฐ€ ์™œ ์ด๊ฑธ ์ด๋ฆฌ ํž˜๋“ค๊ฒŒ..? ๊ทผ๋ฐ ํŒŒ์ด์ฌํ•˜๋ฉด ์ด๊ฑธ ์™œ ์ด๋ ‡๊ฒŒ..? ใ…‹
๋ฐฑ์ค€ 4673๋ฒˆ: ์…€ํ”„๋„˜๋ฒ„ (C++) https://www.acmicpc.net/problem/4673 4673๋ฒˆ: ์…€ํ”„ ๋„˜๋ฒ„ ์…€ํ”„ ๋„˜๋ฒ„๋Š” 1949๋…„ ์ธ๋„ ์ˆ˜ํ•™์ž D.R. Kaprekar๊ฐ€ ์ด๋ฆ„ ๋ถ™์˜€๋‹ค. ์–‘์˜ ์ •์ˆ˜ n์— ๋Œ€ํ•ด์„œ d(n)์„ n๊ณผ n์˜ ๊ฐ ์ž๋ฆฌ์ˆ˜๋ฅผ ๋”ํ•˜๋Š” ํ•จ์ˆ˜๋ผ๊ณ  ์ •์˜ํ•˜์ž. ์˜ˆ๋ฅผ ๋“ค์–ด, d(75) = 75+7+5 = 87์ด๋‹ค. ์–‘์˜ ์ •์ˆ˜ n์ด ์ฃผ์–ด์กŒ์„ ๋•Œ, www.acmicpc.net #include #include #define MAX_NUM 10000 using namespace std; int selfNum(int num) { int sum = num; int d = num; do{ sum += d%10; d = d/10; }while(d!=0); return sum; } int main(void) { int n = 1; ..
๋ฐฑ์ค€ 8958๋ฒˆ: OX ํ€ด์ฆˆ (C++) https://www.acmicpc.net/problem/8958 8958๋ฒˆ: OXํ€ด์ฆˆ "OOXXOXXOOO"์™€ ๊ฐ™์€ OXํ€ด์ฆˆ์˜ ๊ฒฐ๊ณผ๊ฐ€ ์žˆ๋‹ค. O๋Š” ๋ฌธ์ œ๋ฅผ ๋งž์€ ๊ฒƒ์ด๊ณ , X๋Š” ๋ฌธ์ œ๋ฅผ ํ‹€๋ฆฐ ๊ฒƒ์ด๋‹ค. ๋ฌธ์ œ๋ฅผ ๋งž์€ ๊ฒฝ์šฐ ๊ทธ ๋ฌธ์ œ์˜ ์ ์ˆ˜๋Š” ๊ทธ ๋ฌธ์ œ๊นŒ์ง€ ์—ฐ์†๋œ O์˜ ๊ฐœ์ˆ˜๊ฐ€ ๋œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, 10๋ฒˆ ๋ฌธ์ œ์˜ ์ ์ˆ˜ www.acmicpc.net #include #include #include using namespace std; int countOXStr(string ox_str) { int len = ox_str.length(); int sum = 0; int score = 0; for( int i = 0; i < len; i++ ) { auto ox = ox_str.at(i); if( ox == 'O' ) { sc..