fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <time.h>
  4.  
  5. int Fi( int n )
  6. {
  7. if ( n == 1 || n == 2 )
  8. return 1 ;
  9. else
  10. return Fi( n-1 ) + Fi( n-2 ) ;
  11. }
  12.  
  13. int main(void)
  14. {
  15. int n = 0 , m = 0 ;
  16.  
  17. while( scanf( "%d %d", &n , &m ) == 2 )
  18. {
  19. long long int ans = Fi(n) ;
  20. printf( "%d time : %lf\n", ans%( long long int )pow( (double)2.0 , (double)m ) , (double)clock()/CLOCKS_PER_SEC ) ;
  21. }
  22.  
  23. return 0 ;
  24. }
Success #stdin #stdout 0.58s 5264KB
stdin
1 2
4 5
6 7
20 15
40 16
40 20
stdout
1 time : 0.003757
3 time : 0.003757
8 time : 0.003757
6765 time : 0.003757
32459 time : 0.300360
622283 time : 0.584027