File tree Expand file tree Collapse file tree 1 file changed +20
-8
lines changed Expand file tree Collapse file tree 1 file changed +20
-8
lines changed Original file line number Diff line number Diff line change 1
- #include < cstdio>
2
- typedef long long ll;
1
+ #include < iostream>
3
2
4
3
int main (){
5
4
6
- ll t; scanf ( " %lld " , &t) ;
5
+ long t; std::cin >> t ;
7
6
while (t--){
8
- int len; ll n; scanf (" %d %lld" , &len, &n);
9
- ll res (0 ), tmp (n);
10
- while (tmp){res = 10 * res + (tmp % 10 ); tmp /= 10 ;}
11
- while (len--){res *= 10 ;}
12
- printf (" %lld\n " , res);
7
+ long len; std::cin >> len;
8
+ std::string s; std::cin >> s;
9
+
10
+ std::string t (s.size (), ' _' );
11
+ if (s[0 ] != ' 9' ){for (long p = 0 ; p < s.size (); p++){t[p] = ' 0' + (' 9' - s[p]);}}
12
+ else {
13
+ int carry (0 );
14
+ for (long p = s.size () - 1 ; p >= 0 ; p--){
15
+ int a = 1 - carry;
16
+ int b = s[p] - ' 0' ;
17
+ int diff = a - b;
18
+ if (diff < 0 ){carry = 1 ; diff += 10 ;}
19
+ else {carry = 0 ;}
20
+ t[p] = (char )(diff + ' 0' );
21
+ }
22
+ }
23
+
24
+ std::cout << t << std::endl;
13
25
}
14
26
15
27
}
You can’t perform that action at this time.
0 commit comments