結果

問題 No.167 N^M mod 10
ユーザー jjjj
提出日時 2017-01-29 05:28:56
言語 Fortran
(gFortran 13.2.0)
結果
WA  
実行時間 -
コード長 713 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 26,824 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 14:18:57
合計ジャッジ時間 1,449 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

program main
  implicit none
  character*10000::SM,SN
  integer::N,M,i,nlen,mlen
  integer::ntail,mtail,mtail2
  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(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(mtail2*10+mtail-1,4)+1),10)
  end select
end program main
0