题目链接:https://codeforces.com/contest/1700/problem/B
#include<iostream>
#include <string.h>
#include<string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
int u;
cin>>u;
for(int i=1;i<=u;i++)
{int le;
char arr[110000];
int num[110000];
int num1[110000];
cin>>le;
for(int i=le-1;i>=0;i--){
cin>>arr[i];
num[i]=arr[i]-'0';
}
//num数组是反的
num1[0]=1;
if(num[le-1]==9){
for(int i=0;i<=le-1;i++){
num1[i+1]=1;
if(num1[i]-num[i]<0){
num1[i+1]--;
num1[i]=10+num1[i]-num[i];
} else{
num1[i]=num1[i]-num[i];
}
}
} else{
for(int i=0;i<le;i++){
num1[i]=9-num[i];
}
}
for(int i=le-1;i>=0;i--){
cout<<num1[i];
}cout<<endl;
}
return 0;
}
标签:1700,le,contest,int,codeforces,num,include
From: https://www.cnblogs.com/shenqimaomaoxia/p/18576989