#include int main(void) { int n,f=0,a=0,c=0; scanf("%d",&n); char s[n+1]; scanf("%s",s); for(int i=0;i=0;i--) { if(s[i]=='B') f=1; if(f==1 && s[i]=='R') ++a; } if(a && a=0;i--) { if(s[i]=='R') f=1; if(f==1 && s[i]=='B') ++a; } if(a && a 풀이 : 그리디? 1. 왼쪽에서 출발, 오른쪽에서 출발 2가지 경우2. 여기서 B 가 발견 된 다음 이후 나머지 A를 옮기는 경우, A가 발견된 다음 나머지 B를 옮기는 경우 총 4가지 경우를 고려하면 됩니다. 그 중 가장 최솟값을 출력하면 됩니다. https://www.acm..
var a,b,c,d:word;beginrepeatread(a,b,c,d);if a+b+c+d=0 then break;if a+b=3 then a:=0else if ab then if a>b then a:=90-a*10-b else a:=90-b*10-aelse a:=7-a;if c+d=3 then c:=0else if cd then if c>d then c:=90-c*10-d else c:=90-d*10-celse c:=7-c;if a=c then writeln('Tie.') else begin if a 풀이 : 구현, 많은 조건 분기 입력받은 값에 대해서 문제 조건에 맞추어 tier를 부여한 다음,tier가 같다면 Tie.다르다면 더욱 tier 숫자가 낮은 쪽이 이겼다고 출력했습니다. 1,2 2..
var a,b,c,d:word;beginrepeatread(a,b,c,d);if a+b+c+d=0 then break;if a+b=3 then a:=0else if ab then if a>b then a:=90-a*10-b else a:=90-b*10-aelse a:=7-a;if c+d=3 then c:=0else if cd then if c>d then c:=90-c*10-d else c:=90-d*10-celse c:=7-c;if a=c then writeln('Tie.') else begin if a 풀이 : 구현, 많은 조건 분기 입력받은 값에 대해서 문제 조건에 맞추어 tier를 부여한 다음,tier가 같다면 Tie.다르다면 더욱 tier 숫자가 낮은 쪽이 이겼다고 출력했습니다. 1,2 2..
uses math;var s:string;x,y,c,a,b:real;n,m:int64;beginreadln(n,x,y);repeatn-=1;if n=0 then break;readln(s);m:=length(s);c:=1;a:=0;while s[m]' 'do begin a+=c*(ord(s[m])-48); m-=1; c*=10;end;b:=a/sqrt(2);if s[1]='N'then begin if s[2]='E'then begin x+=b;y+=b;end else if s[2]='W'then begin x-=b;y+=b;end else y+=a;endelse if s[1]='S'then begin if s[2]='E'then begin x+=b;y-=b;end else if s[2]='W'then b..
var n,a,b,c,d,e:int64;beginread(n,a,b);d:=0;e:=0;repeatn-=1;read(c);if c=a then d:=1;if c=b then e:=1;until n=1;if e+d=0 then write(-1)else if(d=1)and(e=0)then write(b)else if(d=0)and(e=1)then write(a)else for n:=a to b do write(n,' ');end. 풀이 : 많은 조건 분기? 1. 최소값, 최댓값이 입력되었다면 a~b 전부를 출력합니다.2. 최소값만 입력되었다면 최댓값을 출력합니다.3. 최댓값만 입력되었다면 최솟값을 출력합니다.4. 둘 다 입력되지 않았다면 기억이 잘못된것이므로 -1 을 출력합니다.
var s:string;a,b:int64;beginreadln(s);a:=(ord(s[6])-48)*10+ord(s[7])-48;b:=(ord(s[9])-48)*10+ord(s[10])-48;if((a=3)and(b>20))or((a=4)and(b19))or((a=5)and(b20))or((a=6)and(b20))or((a=7)and(b22))or((a=8)and(b22))or((a=9)and(b22))or((a=10)and(b22))or((a=11)and(b22))or((a=12)and(b21))or((a=1)and(b19))or((a=2)and(b18))or((a=3)and(b 풀이 : 구현, 많은 조건 분기 1. year 는 무시하고, month 와 day를 입력에서 받아옵니다.2. 문제에서 말하는..
var a,b,x,y,z:int64;beginread(a,b);if a=0 then write(0)else if ab then begin write(a div b,' '); x:=b;a:=a mod b;y:=a;z:=y; while 1=1 do begin if x mod y = 0 then break else begin z:=x mod y; x:=y mod x;y:=z;end; end; write(a div z,'/',b div z);end;end. 풀이 : 많은 조건 분기, 유클리드 호제법 1. numerator 가 0 인 경우 -> 0 출력2. numerator 최대공약수를 구한 다음 기약분수 꼴로 출력3. numerator == denominator 인 경우 -> 몫을 출력4. n..
#include #include typedef struct A{ int diff, sell; }A;int arr[24];A left[531441], right[531441];int cmp(const void *a, const void *b) { return ((A*)a)->diff-((A*)b)->diff;}void dfs(int cnt, int goal, int offset, int diff, int sell, int* point, A save[]) { if(cnt == goal) { save[*point].diff = diff; save[*point].sell = sell; (*point)++; return; } dfs(cnt+1,goal,offset,diff+arr[cnt+offset],se..
#include #include int n,m,mid,leftCnt,rightCnt,leftPoint,rightPoint;long long ans = 1e18, k, tmp, P[32],V[32], budget=0;typedef struct A{ long long price, value;}A;int cmp(const void*a, const void*b) { long long c = ((A*)a)->value - ((A*)b)->value; if(c>0) c=1; else if(c>1; diff = gray ^ prevGray; changeBitIndex = __builtin_ctz(diff); if(gray >> changeBitIndex & 1) { value += V[changeBitI..
- Total
- Today
- Yesterday
- find
- 최소 스패닝 트리
- DP
- 그래프
- 오프라인 쿼리
- 정렬
- 브루트포스
- 덱
- BFS
- C++
- C언어
- 누적 합
- 세그먼트 트리
- 스택
- 누적합
- 백준
- union
- Lazy Propagation
- DFS
- 1835
- Segment Tree
- PASCAL
- 문자열
- 1835번
- 그리디
- 구현
- Krustal
- 기하학
- XOR
- java
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
