hf99 • 13小时前
using namespace std; typedef long long ll;
int digitSum(ll x) {
int s = 0;
while (x > 0)
{
s += x % 10;
x /= 10;
}
return s;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--)
{
ll type;
int m;
cin >> type >> m;
for (int i = 0; i < m; i++)
{
ll x;
cin >> x;
ll res = x;
if (type == 1)
{
res = digitSum(res);
}
else if (type >= 2)
{
res = digitSum(res);
res = digitSum(res);
}
if (i > 0) cout << " ";
cout << res;
}
cout << "\n";
}
return 0;
}
评论:
请先登录,才能进行评论