Search

๋ฐฐ์—ด

ํƒœ๊ทธ

2577. ์ˆซ์ž์˜ ๊ฐœ์ˆ˜

๋ฌธ์ œ

์„ธ ๊ฐœ์˜ ์ž์—ฐ์ˆ˜ A, B, C๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ A ร— B ร— C๋ฅผ ๊ณ„์‚ฐํ•œ ๊ฒฐ๊ณผ์— 0๋ถ€ํ„ฐ 9๊นŒ์ง€ ๊ฐ๊ฐ์˜ ์ˆซ์ž๊ฐ€ ๋ช‡ ๋ฒˆ์”ฉ ์“ฐ์˜€๋Š”์ง€๋ฅผ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.
์˜ˆ๋ฅผ ๋“ค์–ด A = 150, B = 266, C = 427 ์ด๋ผ๋ฉดย A ร— B ร— C = 150 ร— 266 ร— 427 = 17037300 ์ด ๋˜๊ณ ,ย ๊ณ„์‚ฐํ•œ ๊ฒฐ๊ณผ 17037300 ์—๋Š” 0์ด 3๋ฒˆ, 1์ด 1๋ฒˆ, 3์ด 2๋ฒˆ, 7์ด 2๋ฒˆ ์“ฐ์˜€๋‹ค.

์ž…๋ ฅ

์ฒซ์งธ ์ค„์— A, ๋‘˜์งธ ์ค„์— B, ์…‹์งธ ์ค„์— C๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. A, B, C๋Š” ๋ชจ๋‘ 100๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ย ๊ฐ™๊ณ , 1,000๋ณด๋‹ค ์ž‘์€ ์ž์—ฐ์ˆ˜์ด๋‹ค.

์ถœ๋ ฅ

์ฒซ์งธ ์ค„์—๋Š” A ร— B ร— C์˜ ๊ฒฐ๊ณผ์— 0 ์ด ๋ช‡ ๋ฒˆ ์“ฐ์˜€๋Š”์ง€ ์ถœ๋ ฅํ•œ๋‹ค. ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๋‘˜์งธ ์ค„๋ถ€ํ„ฐ ์—ด ๋ฒˆ์งธ ์ค„๊นŒ์ง€ A ร— B ร— C์˜ ๊ฒฐ๊ณผ์— 1๋ถ€ํ„ฐ 9๊นŒ์ง€์˜ ์ˆซ์ž๊ฐ€ ๊ฐ๊ฐ ๋ช‡ ๋ฒˆ ์“ฐ์˜€๋Š”์ง€ ์ฐจ๋ก€๋กœ ํ•œ ์ค„์— ํ•˜๋‚˜์”ฉ ์ถœ๋ ฅํ•œ๋‹ค.

์˜ˆ์ œ ์ž…๋ ฅ 1

150 266 427
Plain Text
๋ณต์‚ฌ

์˜ˆ์ œ ์ถœ๋ ฅ 1

3 1 0 2 0 0 0 2 0 0
Plain Text
๋ณต์‚ฌ

ํ’€์ด

๋‚ด ํ’€์ด

#include <bits/stdc++.h> using namespace std; using ll = long long; int freq[10]; int main() { ios::sync_with_stdio(0); cin.tie(0); int a, b, c; cin >> a >> b >> c; ll result = a * b * c; // long long ํƒ€์ž…์„ string ์œผ๋กœ ๋ณ€ํ™˜ string str = to_string(result); for (auto s : str) { freq[s - '0']++; } for (int i = 0; i < 10; i++) { cout << freq[i] << '\n'; } }
C++
๋ณต์‚ฌ
โ€ข
using ํ‚ค์›Œ๋“œ: type alias
โ€ข
to_string() : ์ˆซ์ž ํƒ€์ž… โ†’ string ๋ณ€ํ™˜

๋ณ„ํ•ด

// Authored by : BaaaaaaaaaaarkingDog // Co-authored by : OceanShape // http://boj.kr/fefbce1d30c9442db611909c690df1a8 #include <bits/stdc++.h> using namespace std; int main(void) { ios::sync_with_stdio(0); cin.tie(0); int A, B, C; cin >> A >> B >> C; int t=A*B*C; int d[10] = {}; // ๊ณ„์‚ฐ ๊ฒฐ๊ณผ๋ฅผ ์ž๋ฆฟ์ˆ˜๋ณ„๋กœ ํ™•์ธํ•˜์—ฌ ์ €์žฅ while (t>0) { d[t%10]++; t/=10; } for (int i=0; i<10; ++i) cout << d[i] << '\n'; }
C++
๋ณต์‚ฌ