The addition of large numbers is a copy template. Note that if M is smaller than 3, it will definitely not work, because the smallest is a triangle. The value range of M is 3 <= m <= n + p.
# Include <iostream> # include <string> using namespace STD; string n, m, p; string sum (string S1, string S2) {If (s1.length () <s2.length () {string temp = S1; S1 = S2; S2 = temp;} For (INT n1 = s1.length ()-1, n2 = s2.length ()-1; n1> = 0; N1 --, N2 --) {S1 [N1] = char (S1 [N1] + (N2> = 0? S2 [n2]-'0': 0); If (S1 [N1]-'0'> = 10) {S1 [N1] = char (S1 [N1]-'0') % 10 + '0'); If (N1) S1 [n1-1] ++; else S1 = '1' + S1 ;}} return S1 ;}int main () {While (CIN >>n> M >> p) {int len_n = n. length (); int len_m = m. length (); If (len_m = 1 & M <"3") printf ("NO \ n "); else if (len_m <len_n | len_m = len_n & M <n) printf ("Yes \ n"); else {string temp = sum (n, p ); int len_t = temp. length (); If (len_t> len_m | (len_t = len_m & (temp> M | temp = m) printf ("Yes \ n "); else printf ("NO \ n") ;}// system ("pause"); Return 0 ;}