每日

include

include

using namespace std;

int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector a(n), b(n + 1), c(n + 1);

for (int i = n - 1; i >= 0; i--)
{
char c;
cin >> c;
a[i] = c - '0';
}

if (a[n - 1] == 9)
{
for (int i = 0; i <= n; ++i)
{
b[i] = 1;
}
}
else
{
for (int i = 0; i < n; ++i)
{
b[i] = 9;
}
}

for (int i = 0; i < n; i++)
{
if (b[i] < a[i])
{
b[i + 1]--;
b[i] += 10;
}
c[i] = b[i] - a[i];
}

for (int i = n - 1; i >= 0; i--)
{
cout << c[i];
}
cout << '\n';
}
return 0;
}

posted @ 2024-11-29 22:04  52H1Z  阅读(27)  评论(0)    收藏  举报