//https://www.acmicpc.net/problem/6679 #include <iostream> | |
using namespace std; | |
int main(){ | |
for(int i=1000; i<=9999; i++){ | |
int a=0, b=0; | |
int tmp=i; | |
while(tmp>0){ | |
a+=tmp%10; | |
tmp/=10; | |
} | |
tmp=i; | |
while(tmp>0){ | |
b+=tmp%12; | |
tmp/=12; | |
} | |
if(a!=b) continue; | |
tmp=i; | |
b=0; | |
while(tmp>0){ | |
b+=tmp%16; | |
tmp/=16; | |
} | |
if(a!=b) continue; | |
cout << i<<endl; | |
} | |
return 0; | |
} |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
180518_14623_감정이입 (0) | 2018.05.18 |
---|---|
18505_2751_수 정렬하기 2(합병정렬) (0) | 2018.05.05 |
180504_2751_수 정렬하기 2 (퀵정렬) (0) | 2018.05.04 |
180503_3460_이진수 (0) | 2018.05.03 |
180502_2576_홀수 (0) | 2018.05.02 |
//https://www.acmicpc.net/problem/6679 #include <iostream> | |
using namespace std; | |
int main(){ | |
for(int i=1000; i<=9999; i++){ | |
int a=0, b=0; | |
int tmp=i; | |
while(tmp>0){ | |
a+=tmp%10; | |
tmp/=10; | |
} | |
tmp=i; | |
while(tmp>0){ | |
b+=tmp%12; | |
tmp/=12; | |
} | |
if(a!=b) continue; | |
tmp=i; | |
b=0; | |
while(tmp>0){ | |
b+=tmp%16; | |
tmp/=16; | |
} | |
if(a!=b) continue; | |
cout << i<<endl; | |
} | |
return 0; | |
} |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
180518_14623_감정이입 (0) | 2018.05.18 |
---|---|
18505_2751_수 정렬하기 2(합병정렬) (0) | 2018.05.05 |
180504_2751_수 정렬하기 2 (퀵정렬) (0) | 2018.05.04 |
180503_3460_이진수 (0) | 2018.05.03 |
180502_2576_홀수 (0) | 2018.05.02 |