Breaking a number such that first part is integral division of second by a power of 10 | C # program to count ways to divide a String in two parts a and b such that b / pow ( 10 , p ) == a ; subString representing int a ; no of digits in a ; consider only most significant l1 characters of remaining String for int b ; if any of a or b contains leading 0 s discard this combination ; if both are equal ; Driver Code
using System ; class GFG { static int calculate ( String N ) { int len = N . Length ; int l = ( len ) / 2 ; int count = 0 ; for ( int i = 1 ; i <= l ; i ++ ) { String s = N . Substring ( 0 , i ) ; int l1 = s . Length ; String t = N . Substring ( i , l1 ) ; if ( s [ 0 ] == '0' t [ 0 ] == '0' ) continue ; if ( s . CompareTo ( t ) == 0 ) count ++ ; } return count ; } public static void Main ( String [ ] args ) { String N = "2202200" ; Console . Write ( calculate ( N ) ) ; } }