結果

問題 No.167 N^M mod 10
ユーザー jjjj
提出日時 2017-01-29 05:32:20
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 724 bytes
コンパイル時間 2,211 ms
コンパイル使用メモリ 31,896 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 00:13:53
合計ジャッジ時間 3,256 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  character*10000::SM,SN
  integer::N,M,i,nlen,mlen
  integer::ntail,mtail,mtail2,mtail3
  data mtail2/0/
  read *,SN
  read *,SM
  nlen = LEN_TRIM(SN)
  mlen = LEN_TRIM(SM)
  ntail = ICHAR(SN(nlen:nlen))-ICHAR('0')

  if(mlen.eq.1.and.SM(1:1).eq.'0') then
     print '(i0)', 1
     return
  end if

  select case (ntail)
  case(0,1,5,6)
     print '(i0)', ntail
  case(4,9)
     mtail = ICHAR(SM(mlen:mlen))-ICHAR('0')
     print '(i0)', MOD(ntail**(MOD(2+mtail-1,2)+1),10)
  case(2,3,7,8)
     mtail = ICHAR(SM(mlen:mlen))-ICHAR('0')
     if(mlen.ge.2) mtail2 = ICHAR(SM(mlen-1:mlen-1))-ICHAR('0')
     print '(i0)', MOD(ntail**(MOD(4+mtail2*10+mtail-1,4)+1),10)
  end select
end program main
0