
intercoms : 인터폰 (구내전화)
resident : 주민, 거주자
대회 중에 문제 이해 잘 안 됐는데 지금 다시 보니 알겠다. 11, 111 이런게 지루한 아파트 번호이고 얘가 이 번호로 계속 전화를 걸다가 누가 받으면 끊는다는구나.
문제 그대로 구현했다. 1부터 9까지 가는데 각 수마다 1, 11, 111, 1111 찍었다. 그리고 문자열 길이 더해나갔음
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <bitset>
 
#define xx first
#define yy second
#define all(x) (x).begin(), (x).end()
 
using namespace std;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
using iii = tuple<int, int, int>;
 
void	solve()
{
	string str;
	cin >> str;
 
	int cnt = 0;
	for (int i = 1; i <= 9; i++)
	{
		string tmp = "";
 
		for (int j = 0; j < 4; j++)
		{
			tmp += i + '0';
			cnt += tmp.size();
			if (tmp == str)
			{
				printf("%d\n", cnt);
				return;
			}
		}
 
	}
}
 
int     main()
{
	int t;
	scanf("%d", &t);
 
	for (int i = 0; i < t; i++)
	{
		solve();
	}
}'코드포스' 카테고리의 다른 글
| [코드포스 Round 677] C. Dominant Piranha (0) | 2020.11.07 | 
|---|---|
| [코드포스 Round 677] B. Yet Another Bookshelf (0) | 2020.11.07 | 
| [코드포스 Round 677] 후기 (0) | 2020.11.07 | 
| D. AND, OR and square sum (0) | 2020.07.10 | 
| [코드포스 Practice22] E. Restaurant (0) | 2020.07.05 | 
 
                  
                 
                  
                 
                  
                