-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdiff_Main.cpp
More file actions
50 lines (46 loc) · 1.26 KB
/
Copy pathdiff_Main.cpp
File metadata and controls
50 lines (46 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
diff --git a/CodeJam/Main.cpp b/examples/2022/KS_A/B/Main.cpp
index 2150379..6de7373 100644
--- a/CodeJam/Main.cpp
+++ b/examples/2022/KS_A/B/Main.cpp
@@ -5,7 +5,7 @@
#define IA_ERROR_CODE -1
#define IA_COMM_LOG //add comment on this line, to deactivate the interactive communication error log
// #define XY_NOTATION //remove commment on this line, to activate xy notation on complex numbers
-#define COMM_TYPE ll
+#define COMM_TYPE str
// The maintained and empty code template can be found at:
// https://github.com/demmerichs/CodeJamTemplate
@@ -1570,11 +1570,36 @@ void init(){
cin >> T;
}
+str N;
+
void readInput(){
+ cin >> N;
}
// write to COMM_TYPE result
void calcFunction() {
+ result = "99" + N;
+
+ ll sod = 0;
+ forn(i, N.sz){
+ sod += N[i] - '0';
+ }
+ ll rest = sod % 9;
+
+ v(char) add_digits;
+ add_digits.pb('0' + (9 - rest));
+ if(rest == 0)
+ add_digits.pb('0');
+
+ forn(i, add_digits.sz){
+ char add = add_digits[i];
+ forn(pos, N.sz+1){
+ str cur_poss = N.substr(0, pos) + add + N.substr(pos, N.sz-pos);
+ lg(cur_poss);
+ if(cur_poss < result && cur_poss[0] > '0')
+ result = cur_poss;
+ }
+ }
}
} // namespace task