結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | 37zigen |
提出日時 | 2018-03-05 02:40:42 |
言語 | Fortran (gFortran 13.2.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 1,188 bytes |
コンパイル時間 | 167 ms |
コンパイル使用メモリ | 32,256 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-01 16:09:00 |
合計ジャッジ時間 | 758 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
5,248 KB |
testcase_01 | AC | 3 ms
5,248 KB |
testcase_02 | AC | 3 ms
5,248 KB |
testcase_03 | AC | 4 ms
5,248 KB |
testcase_04 | AC | 4 ms
5,248 KB |
testcase_05 | AC | 4 ms
5,248 KB |
testcase_06 | AC | 4 ms
5,248 KB |
testcase_07 | AC | 3 ms
5,248 KB |
testcase_08 | AC | 3 ms
5,248 KB |
testcase_09 | AC | 3 ms
5,248 KB |
testcase_10 | AC | 3 ms
5,248 KB |
testcase_11 | AC | 3 ms
5,248 KB |
testcase_12 | AC | 4 ms
5,248 KB |
testcase_13 | AC | 4 ms
5,248 KB |
testcase_14 | AC | 3 ms
5,248 KB |
testcase_15 | AC | 3 ms
5,248 KB |
testcase_16 | AC | 3 ms
5,248 KB |
コンパイルメッセージ
Main.f90:11:20: 10 | do i=0,size(isPrime) | 2 11 | isPrime(i)=.true. | 1 Warning: Array reference at (1) out of bounds (10001 > 10000) in loop beginning at (2) Main.f90:32:15: 31 | do i=0,size(dp) | 2 32 | dp(i)=.true. | 1 Warning: Array reference at (1) out of bounds (10001 > 10000) in loop beginning at (2) Main.f90:45:15: 37 | do i=2,size(dp) | 2 ...... 45 | dp(i)=flag | 1 Warning: Array reference at (1) out of bounds (10001 > 10000) in loop beginning at (2) Main.f90:11:29: 11 | isPrime(i)=.true. | ^ Warning: iteration 10001 invokes undefined behavior [-Waggressive-loop-optimizations] Main.f90:10:11: 10 | do i=0,size(isPrime) | ^ note: within this loop Main.f90:16:15: 16 | if(isPrime(i)) then | ^ Warning: iteration 9999 invokes undefined behavior [-Waggressive-loop-optimizations] Main.f90:15:11: 15 | do i=2,size(isPrime) | ^ note: within this loop Main.f90:24:15: 24 | if(isPrime(i))then | ^ Warning: iteration 10001 invokes undefined behavior [-Waggressive-loop-optimizations] Main.f90:23:11: 23 | do i=0,size(isPrime) | ^ note: within this loop Main.f90:32:24: 32 | dp(i)=.true. | ^ Warning: iteration 10001 invokes undefined behavior [-Waggressive-loop-optimizations] Main.f90:31:11: 31 | do i=0,size(dp) | ^ note: within this loop Main.f90:45:22: 45 | dp(i)=flag | ^ Warning: iteration 9999 invokes undefined behavior [-Waggressive-loop-optimizations] Main.f90:37:11: 37 | do i=2,size(dp) | ^ note: within this loop
ソースコード
program main implicit none logical::isPrime(0:10000) logical::dp(0:10000) logical::is Integer::i,j,k,l,p=0,n Integer::primes(0:10000) logical::flag do i=0,size(isPrime) isPrime(i)=.true. end do isPrime(0)=.false. isPrime(1)=.false. do i=2,size(isPrime) if(isPrime(i)) then do j=2*i,size(isPrime),i isPrime(j)=.false. end do end if end do do i=0,size(isPrime) if(isPrime(i))then primes(p)=i p=p+1 end if end do do i=0,size(dp) dp(i)=.true. end do do i=2,size(dp) flag=.false. do j=0,p flag=flag .or. (i-primes(j)>=0 .and. .not. dp(i-primes(j))) if(flag)then exit end if end do dp(i)=flag end do read*,n if(dp(n))then print'("Win")' else print'("Lose")' end if end program main