Last active
December 30, 2018 14:21
-
-
Save JoeUnsung/bb850ba43bab3bf9aa95f536a5a792e4 to your computer and use it in GitHub Desktop.
BAEK_JOON_ONLINE_JUDGE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| """ | |
| BJ Judge solution | |
| """ | |
| ## 입출력 받아보기 | |
| ## 11718 | |
| while True : | |
| try : | |
| print(input()) | |
| except EOFError : | |
| break | |
| ## 사칙 연산 | |
| ## 10998 | |
| a, b = input().split() | |
| print(int(a) * int(b)) | |
| ## | |
| a, b = input().split() | |
| print(int(a) / int(b)) | |
| ## | |
| a, b = input().split() | |
| print(int(a) + int(b)) | |
| print(int(a) - int(b)) | |
| print(int(a) * int(b)) | |
| print(int(a) // int(b)) | |
| print(int(a) % int(b)) | |
| ## | |
| a, b, c = input().split() | |
| print((int(a) + int(b)) % int(c)) | |
| print(((int(a)%int(c)) + (int(b)%int(c)) ) %int(c)) | |
| print((int(a) * int(b)) % int(c)) | |
| print(((int(a)%int(c)) * (int(b)%int(c)) ) %int(c)) | |
| ## | |
| x = int(input()) | |
| min = 0 | |
| n = 0 | |
| while 1 : | |
| if x%3 == 0 and x >= 0 : | |
| min = x//3 + n | |
| if x <= 0 : | |
| if min != 0 : | |
| break | |
| else : | |
| min = -1 | |
| break | |
| else : | |
| x += -5 | |
| n += 1 | |
| print(min) | |
| ## for | |
| ### 1 | |
| ### 2 | |
| x=int(input()) | |
| for i in range(x,0,-1): | |
| print(i) | |
| ### 3 | |
| x=int(input()) | |
| for i in range(1,10): | |
| print("%d * %d = %d" %(x,i,i*x)) | |
| ## 4 | |
| x=int(input()) | |
| star="" | |
| for i in range(0,x): | |
| star+="*" | |
| print(star) | |
| ## 5 | |
| x=int(input()) | |
| star="" | |
| for i in range(0,x): | |
| star+="*" | |
| print(star.rjust(x)) | |
| ## 6 | |
| x=int(input()) | |
| star="*" | |
| for i in range(x,0,-1): | |
| print(star*i) | |
| ## 7 | |
| x=int(input()) | |
| star="*" | |
| for i in range(x): | |
| print(' '*i+star*(x-i)) | |
| ## 8 | |
| x, y= input().split() | |
| x=int(x) | |
| y=int(y) | |
| res = 0 | |
| for i in range (x,0,-1): | |
| if i == x: | |
| res+=y | |
| continue | |
| if i in (1,3,5,7,8,10): | |
| res+=31 | |
| elif i in (4,6,9,11): | |
| res+=30 | |
| else : | |
| res+=28 | |
| res%=7 | |
| if res==0: | |
| print("SUN") | |
| elif res==1: | |
| print("MON") | |
| elif res==2: | |
| print("TUE") | |
| elif res==3: | |
| print("WED") | |
| elif res==4: | |
| print("THU") | |
| elif res==5: | |
| print("FRI") | |
| else: | |
| print("SAT") | |
| ## 9 | |
| x=int(input()) | |
| sum=0 | |
| for i in range(x+1): | |
| sum += i | |
| print(sum) | |
| ## 10 | |
| x=int(input()) | |
| y=input() | |
| numSet=[] | |
| cnt=0 | |
| for i in y: | |
| numSet.append(int(y[cnt])) | |
| cnt+=1 | |
| sum=0 | |
| for i in numSet: | |
| sum += i | |
| print(sum) | |
| ## 11 | |
| x="OneTwoThreeFourFiveSixSevenEightNineTen" | |
| #x=input() | |
| cnt=0 | |
| for i in x: | |
| print(i, end="") | |
| cnt+=1 | |
| if cnt%10==0 : | |
| print() | |
| ## For | |
| ## 1 | |
| x=int(input()) | |
| if 90<=x<=100: | |
| print("A") | |
| elif 80<=x<90: | |
| print("B") | |
| elif 70<=x<80: | |
| print("C") | |
| elif 60<=x<70: | |
| print("D") | |
| else : | |
| print("F") | |
| ## 2 | |
| x=[] | |
| x=input().split() | |
| x=[int(i) for i in x] | |
| x.sort() | |
| print(x[1]) | |
| ## 3 | |
| x=[];y=[];temp=[]; | |
| x=input().split() | |
| y=input().split() | |
| x=[int(i) for i in x] | |
| y=[int(i) for i in y] | |
| for i in y: | |
| if i < x[1] : | |
| temp.append(i) | |
| for i in temp: | |
| print(i, end=' ') | |
| ## 4 | |
| ##-1 | |
| x=int(input()) | |
| y=list(map(int, input().split())) | |
| print( (100*sum(nlist))/(N*max(nlist)) ) | |
| ##-2 | |
| x=int(input()) | |
| y=input().split() | |
| y=[int(i) for i in y] | |
| y.sort() | |
| max=y[len(y)-1] | |
| num=0 | |
| for i in y: | |
| num+=i/max*100 | |
| num/=x | |
| print(num) | |
| ## 5 | |
| x=int(input());avg_cnt=[];avg_temp=0; | |
| for i in range(x): | |
| y=list(map(int, input().split())) | |
| avg_temp=sum(y[1:])/y[0] | |
| #print(avg_temp) | |
| cnt=0 | |
| for j in y[1:]: | |
| if avg_temp < j: | |
| cnt+=1 | |
| avg_cnt.append(round(cnt/y[0]*100, 3)) | |
| for i in range(x): | |
| temp = str("%0.3f" %avg_cnt[i]) | |
| print(temp+"%") | |
| ## 6 | |
| num=int(input());x=num;cnt=0; | |
| for z in range(100): | |
| num=z;x=num;cnt=0; | |
| while 1 : | |
| cnt+=1 | |
| ## digit of 10 | |
| temp10=str(x)[len(str(x))-1] | |
| ## digit of 1 | |
| if x >= 10 : | |
| temp1=int(str(x)[0]) + int(str(x)[1]) | |
| else : | |
| temp1 = int(str(x)[0]) | |
| temp1=str(temp1%10) | |
| #print(temp10 + temp1) ## str <-- temp1 and temp10 | |
| isSame=int(temp10 + temp1) | |
| if isSame==num : | |
| print(cnt) | |
| break | |
| else : | |
| x=isSame | |
| num=int(input());x=num;cnt=0; | |
| while 1 : | |
| cnt+=1 | |
| ## digit of 10 | |
| temp10=str(x)[len(str(x))-1] | |
| ## digit of 1 | |
| if x >= 10 : | |
| temp1=int(str(x)[0]) + int(str(x)[1]) | |
| else : | |
| temp1 = int(str(x)[0]) | |
| temp1=str(temp1%10) | |
| #print(temp10 + temp1) ## str <-- temp1 and temp10 | |
| isSame=int(temp10 + temp1) | |
| if isSame==num : | |
| print(cnt) | |
| break | |
| else : | |
| x=isSame | |
| ## def | |
| ## 1 | |
| def selfNum(n): | |
| if 0<= n < 10 : | |
| return n+n | |
| elif 10<= n < 100 : | |
| return n+ int(str(n)[0]) + int(str(n)[1]) | |
| elif 100<=n<1000: | |
| return n+ int(str(n)[0]) + int(str(n)[1]) + int(str(n)[2]) | |
| elif 1000<=n<10000: | |
| return n+ int(str(n)[0]) + int(str(n)[1]) + int(str(n)[2]) + int(str(n)[3]) | |
| else : | |
| return n+ int(str(n)[0]) + int(str(n)[1]) + int(str(n)[2]) + int(str(n)[3]) + int(str(n)[4]) | |
| ## list 초기화하는 부분 | |
| n=1;list=[]; | |
| for i in range(10000): | |
| list.append(0) | |
| for i in range(1,10000): | |
| n=i | |
| cnt=0 ## 처음 시작하는 숫자가 포함되지 않도록 조절하는 인자 | |
| while n <= 10000 : | |
| if cnt==0: | |
| cnt+=1 | |
| n=selfNum(n) | |
| #print(n) | |
| continue | |
| list[n-1]+=1 | |
| n=selfNum(n) | |
| #print(n) | |
| for i in range(10000): | |
| if list[i]==0: | |
| print(i+1) | |
| ## 2 | |
| x=int(input()) | |
| cnt=0 | |
| for i in range(1,x+1): | |
| if 1<= i <100: | |
| cnt+=1 | |
| continue | |
| temp1= int(str(i)[0]) - int(str(i)[1]) | |
| temp2= int(str(i)[1]) - int(str(i)[2]) | |
| if temp1==temp2: | |
| cnt+=1 | |
| print(cnt) | |
| ## 3 | |
| ## 1차원 배열 활용 | |
| ## 1 | |
| x= input() | |
| cnt=0 | |
| switch=0 | |
| for i in range(len(x)): | |
| if x[i]!=' ' and switch==0: | |
| switch=1 | |
| cnt+=1 | |
| elif x[i]==' ' and switch==1: | |
| switch=0 | |
| print(cnt) | |
| words = input().split() | |
| print(len(words)) | |
| ## 2 | |
| x=int(input()) | |
| y=int(input()) | |
| z=int(input()) | |
| res=str(x*y*z) | |
| for i in range(10): | |
| a=str(i) | |
| print(res.count(a)) | |
| ## 3 | |
| posi=int(input()); | |
| sumcnt=[] | |
| for i in range(posi): | |
| x=input() | |
| cnt=0 | |
| temp=0 | |
| for i in x: | |
| if i=='O': | |
| cnt+=1 | |
| temp+=cnt | |
| else : | |
| cnt=0 | |
| sumcnt.append(temp) | |
| for i in sumcnt: | |
| print(i) | |
| ## 4 | |
| x=input().split() | |
| cnt=0 | |
| for i in range(7): | |
| temp = int(x[i]) - int(x[i+1]) | |
| if temp == 1 : | |
| cnt+=1 | |
| elif temp == -1 : | |
| cnt-= 1 | |
| if cnt == -7 : | |
| print("ascending") | |
| elif cnt == 7 : | |
| print("descending") | |
| else : | |
| print("mixed") | |
| ## 5-1 | |
| x=[] | |
| for i in range(5): | |
| x.append(input()) | |
| temp=[]; | |
| for i in x: | |
| if int(i) < 40 : | |
| temp.append(40) | |
| else : | |
| temp.append(int(i)) | |
| print(round(sum(temp)/5)) | |
| ## 5-2 | |
| print(eval("+max(8,int(input())//5)"*5)) | |
| ## 문자열 | |
| ## 1 | |
| print(ord(input())) # 출력 결과: 90 | |
| ## 2 | |
| x=input() | |
| x[0] ## min | |
| x[len(x)-1] ## max | |
| for i in range(97,123): | |
| print(chr(i)) | |
| ## 3 | |
| num=int(input());x=[]; | |
| for i in range(num): | |
| x.append(int(input())) | |
| for i in range(num-1) : | |
| for j in range(num-1) : | |
| if x[j] > x[j+1]: | |
| x[j], x[j+1] = x[j+1], x[j] | |
| for i in x: | |
| print(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment