</pre><pre code_snippet_id="476017" snippet_file_name="blog_20140926_9_2109804" name="code" class="cpp">
#include <iostream> using namespace std ; int height(int n) { int h = 1 ; if ( n== 0) h = h ; else { for ( int i = 1 ; i <= n ; ++i) if ( i % 2 == 0) h += 1 ; else h *= 2 ; } return h ; } int main() { int t ; cin >> t ; // int height = 1 ; while (t--) { int n ; cin >> n ; /*int height = 1 ; if ( n == 0 ) height = height; else { for ( int i = 1 ; i <= n ; ++i) if ( i % 2 == 0) height += 1 ; else height *= 2 ; } cout << height << endl ;*/ cout << height(n) << endl ; } }
</pre><pre code_snippet_id="476017" snippet_file_name="blog_20140926_9_2109804" name="code" class="cpp">
</pre><pre code_snippet_id="476017" snippet_file_name="blog_20140926_8_3429580" name="code" class="cpp">
</pre><pre code_snippet_id="476017" snippet_file_name="blog_20140926_10_2982639" name="code" class="cpp"><pre name="code" class="cpp">#include <iostream> using namespace std ; int main() { int t ; cin >> t ; while (t--) { int n ; cin >> n ; int count = 0 ; int cn = n ; while ( n > 0) { int digit = n % 10 ; if ( digit != 0 && cn %digit == 0) ++count ; n / = 10 ; } cout << endl ; } }