这怎么是WA,明明是对的
查看原帖
这怎么是WA,明明是对的
517175
lxya楼主2021/5/6 23:40

这怎么会出错? 输入

2

3

13

输出

0 1 1 1 0 0 0 0 0 0

1 6 2 2 1 1 1 1 1 1

#include <iostream>
#include <map>
using namespace std;

int main()
{
	int T;
	cin >> T;
	while (T--)
	{
		map<int, int> a{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}};
		int n;
		cin >> n;
		for (int i = 0; i <=n; i++)
		{
			int d = i;
			while (d)
			{
				a[d % 10]++;
				d /= 10;
			}
		}
		for (auto i : a)
		{
			cout << i.second;
			cout << " ";
		}
		cout << endl;
	}
	return 0;
}
2021/5/6 23:40
加载中...