Advertisement
a53

Suma34

a53
Apr 27th, 2017
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. long n , m , i , s , j , a[100000] , t , x ;
  5.  
  6. int main()
  7. {
  8. cin >> n ;
  9. a[1] = 1 ;
  10. m = 1 ;
  11. for ( i = 1 ; i <= n ; i++ )
  12. {
  13. t = 0 ;
  14. for ( j = 1 ; j <= m ; j++ )
  15. {
  16. x = a[j] ;
  17. a[j] = ( a[j] * 2 + t ) % 10000 ;
  18. t = ( x * 2 + t ) / 10000 ;
  19. }
  20. if ( t > 0 ) { m++ ; a[m] = t ;}
  21. }
  22. s = 0 ;
  23. for ( i = 1 ; i <= m ; i++ )
  24. {
  25. x = a[i] ;
  26. while ( x != 0)
  27. {
  28. s = s + x % 10 ;
  29. x = x / 10 ;
  30. }
  31. }
  32. cout << s ;
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement