function get_num(N) result(t) integer::N,t if(MOD(N,400).eq.0) then t = 2 else if(MOD(N,100).eq.0) then t = 1 else if(MOD(N,4).eq.0) then t = 2 else t = 1 end if end function get_num program main implicit none interface function get_num(N) result(t) integer::N,t end function get_num end interface integer::N,M,i,youbi,onaji read *,N M = (N-2014)/400 onaji = 0 youbi = 0 do i=2015,(N-M*400) youbi = MOD(youbi+get_num(i),7) if(youbi.eq.0) then onaji = onaji + 1 end if ! print '(i0," ",i0)', i, youbi end do print '(i0)', onaji + M*57 end program main