알고리즘 문제 풀이/1DP_과제(~180615)

알고리즘 문제 풀이/1DP_과제(~180615)

180615_다음 큰 숫자

자연수 n이 주어졌을 때, n의 다음 큰 숫자는 다음과 같이 정의 합니다.조건 1. n의 다음 큰 숫자는 n보다 큰 자연수 입니다.조건 2. n의 다음 큰 숫자와 n은 2진수로 변환했을 때 1의 갯수가 같습니다.조건 3. n의 다음 큰 숫자는 조건 1, 2를 만족하는 수 중 가장 작은 수 입니다.예를 들어서 78(1001110)의 다음 큰 숫자는 83(1010011)입니다.자연수 n이 매개변수로 주어질 때, n의 다음 큰 숫자를 return 하는 solution 함수를 완성해주세요.제한 사항n은 1,000,000 이하의 자연수 입니다. #include #include #include using namespace std; int solution(int n) { int x=__builtin_popcount(..

알고리즘 문제 풀이/1DP_과제(~180615)

180608_1076_저항

//https://www.acmicpc.net/problem/1076 #include #include #include using namespace std; struct res{ string color; int value; long long int digit;}; res table[10]; void maketable(){ table[0].color="black"; table[0].value=0; table[0].digit=1; table[1].color="brown"; table[1].value=1; table[1].digit=10; table[2].color="red"; table[2].value=2; table[2].digit=100; table[3].color="orange"; table[3].val..

알고리즘 문제 풀이/1DP_과제(~180615)

180607_5597_과제안내신분?

//https://www.acmicpc.net/problem/5597 #include using namespace std; int max(int a, int b) { return a>b ? a : b;}int min(int a, int b) { return a x; chk[x]=1; } int ans1=0, ans2=0; for(int i=1; i

알고리즘 문제 풀이/1DP_과제(~180615)

180604_10769_행복한지 슬픈지

//https://www.acmicpc.net/problem/10769 #include using namespace std; int main(){ char str[256]; cin.getline(str, 255); int cnt[2]={0,0}; for(int i=0; str[i]!=0; i++){ if(str[i]==':' && (str[i+1]!=0 && str[i+2]!=0)){ if(str[i+1]=='-'){ if(str[i+2]==')') cnt[0]++; else if(str[i+2]=='(') cnt[1]++; } } } if(cnt[1]==0 && cnt[0]==0) cout cnt[1]) cout

bong sue
'알고리즘 문제 풀이/1DP_과제(~180615)' 카테고리의 글 목록