시뮬레이션

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

180331_12100_2048(easy)

//https://www.acmicpc.net/problem/12100 #include using namespace std;#define UP 0#define DOWN 1#define LEFT 2#define RIGHT 3int mx=0;int N;int board[20][20][2];int cache[6][20][20];void solve(int dir, int depth); int main(){ cin >> N; for(int i=0; i board[i][j][0]; cache[0][i][j]=board[i][j][0]; } for(int i=0; i

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

171223_1547_공

//https://www.acmicpc.net/problem/1547 #include using namespace std; int main(){ int m; bool cup[4]={0,1,0,0}; cin >> m; for(int i=0 ;i> x >> y; int tmp=cup[x]; cup[x]=cup[y]; cup[y]=tmp; } for(int i=1; i

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

171026_1094_막대기

#include using namespace std; int main(){ int goal; cin >> goal; int t_length=64; int sht=64; int cnt=1; while(t_length>goal) { sht/=2; cnt++; if(t_length-sht>=goal) {t_length-=sht;cnt--;} } cout while(t_length>goal)가지고 있는 막대 중 길이가 가장 짧은 것을 절반으로 자른다. ->sht/=2; 개수는 1개가 2개가 되니 cnt++;만약, 위에서 자른 막대의 절반 중 하나를 버리고 남아있는 막대의 길이의 합이 X보다 크거나 같다면 ->if(t_length-sht>=goal) , 위에서 자른 막대의 절반 중 하나를 버린다. -> t_len..

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

171026_2455_지능형 기차

#include using namespace std; int main(){ int max=0; int n=0; for(int i=0; i> x; n-=x; if(max> x; n+=x; if(max

bong sue
'시뮬레이션' 태그의 글 목록 (2 Page)