Notice
Recent Posts
Recent Comments
Link
«   2025/08   »
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
Archives
Today
Total
관리 메뉴

코딩로그

[백준/BOJ/C++] 13297번 Quick Estimates 본문

YJ/C++

[백준/BOJ/C++] 13297번 Quick Estimates

Team DAON 2021. 11. 5. 14:23

[문제]

Let’s face it... you are not that handy. When you need to make a major home repair, you often need to hire someone to help. When they come for the first visit, they make an estimate of the cost. Here they must be careful: if they overestimate the cost, it might scare you off, but if they underestimate, the work might not be worth their time.

Because the worker is so careful, it can take a long time for them to produce the estimate. But that’s frustrating — when you ask for an estimate, you really are asking for the magnitude of the cost. Will this be $10 or $100 or $1 000? That’s all you really want to know on a first visit.

Please help the worker make the type of estimate you desire. Write a program that, given the worker’s estimate, reports just the magnitude of the cost — the number of digits needed to represent the estimate.

[입력]

Input begins with a line containing an integer N (1 ≤ N ≤ 100). The next N lines each contain one estimated cost, which is an integer between 0 and 10100. (Some of the workmen overcharge quite a bit.)

[출력]

For each estimated cost, output the number of digits required to represent it.

[Source Code]

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int test;
	cin >> test;
	int *arr = new int[test];

	for(int i = 0; i < test; i++){
		string input;
		cin >> input;

		arr[i] = input.length();
	}

	for(int i = 0; i < test; i++)
		cout << arr[i] << "\n";
}

[결과 화면]