結果
問題 |
No.430 文字列検索
|
ユーザー |
![]() |
提出日時 | 2016-10-02 23:42:11 |
言語 | Fortran (gFortran 14.2.0) |
結果 |
AC
|
実行時間 | 638 ms / 2,000 ms |
コード長 | 962 bytes |
コンパイル時間 | 563 ms |
コンパイル使用メモリ | 33,280 KB |
実行使用メモリ | 7,148 KB |
最終ジャッジ日時 | 2024-11-10 00:04:38 |
合計ジャッジ時間 | 6,737 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 14 |
ソースコード
program main implicit none character*50000::S character*10::c(5000) integer*8::snum(50000) integer*8::shash(10,50000) integer*8::chash(5000) integer::clen(5000) integer::M,i,j,slen integer*8::match=0,tmp read *,S read *,M read *,c(1:M) clen(1:M) = LEN_TRIM(c(1:M)) slen = LEN_TRIM(S) do i=1,slen snum(i) = ICHAR(S(i:i))-ICHAR('A') + 1 end do do i=1,slen tmp = 1 do j=1,10 if(i+j-1.gt.slen) exit tmp = tmp + snum(i+j-1) * 26_8**(j-1) shash(j,i) = tmp end do end do do i=1,M tmp = 1 do j=1,clen(i) tmp = tmp + (ICHAR(c(i)(j:j))-ICHAR('A') + 1) * 26_8**(j-1) end do chash(i) = tmp end do do j=1,M tmp = clen(j) ! print '(a,i0)',"chash:",chash(j) ! print *,shash(tmp,1:slen) do i=1,slen if(shash(tmp,i).eq.chash(j)) then match = match + 1 end if end do end do print '(i0)',match end program main