728x90
반응형
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV18_yw6I9MCFAZN
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#include<algorithm>
typedef long long ll;
using namespace std;
int main(void)
{
// 0 ~9 까지니까 1023이면 될듯.
int size,n;
int result,temp,digit;
int mul;
scanf("%d",&size);
for(int i = 0; i < size; i++)
{
scanf("%d",&n);
result = 0;
temp = n;
mul = 1;
while(1)
{
while(temp){
digit = temp % 10;
result |= 1 << digit;
temp /= 10;
}
if(result == 1023) break;
mul++;
temp = n * mul;
}
printf("#%d %d\n",i+1,n*mul);
}
return 0;
}
해결 방법:
0,1,2,3,4,5,6,7,8,9가 다 나오면 끝인건데...
지난번에 했던 스도쿠 검증과 똑같다.
이번엔 0이 추가되었으므로, 비트가 0011 1111 1111 이 나와야한다.
1 << 0 이 1 이므로...
따라서 1023인가? 를 확인해주면 된다.
---END---
728x90
반응형
'컴퓨터 > 알고리즘' 카테고리의 다른 글
[SWEA] 1859. 백만 장자 프로젝트 (0) | 2021.02.03 |
---|---|
[SWEA] 1954. 달팽이 숫자 (0) | 2021.02.02 |
[SWEA] 1974 스도쿠검증 (비트마스크) (0) | 2021.01.29 |
[SWEA] 1979 어디에 단어가 들어갈 수 있을까 (0) | 2021.01.28 |
[SWEA] 1983 조교의 성적 매기기 (0) | 2021.01.27 |