반응형
#include < iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int cnt = 1;
int i = 1;
int j = 10;
int total = 0;
while(1){
if(n<j){
total += (n-i+1)*cnt;
break;
}else{
total += (j-i)*cnt;
i = i*10;
j = j*10;
cnt++;
}
}
cout<<total<<endl;
return 0;
}
https://www.acmicpc.net/problem/1748
1748번: 수 이어 쓰기 1
첫째 줄에 N(1≤N≤100,000,000)이 주어진다.
www.acmicpc.net
반응형
'개발자 > 알고리즘' 카테고리의 다른 글
[BOJ] 14889번 스타트와 링크 (0) | 2019.10.13 |
---|---|
[BOJ] 1339번 단어수학 (0) | 2019.10.13 |
[BOJ] 1261번 알고스팟 -deque (0) | 2019.10.12 |
[BOJ] 13549번 숨바꼭질3 (0) | 2019.10.11 |
[BOJ] 14226번 이모티콘 (0) | 2019.10.08 |