結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | 37zigen |
提出日時 | 2018-03-05 02:38:11 |
言語 | Fortran (gFortran 13.2.0) |
結果 |
AC
|
実行時間 | 8 ms / 5,000 ms |
コード長 | 1,103 bytes |
コンパイル時間 | 1,588 ms |
コンパイル使用メモリ | 32,504 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-01 16:08:44 |
合計ジャッジ時間 | 828 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 8 ms
6,816 KB |
testcase_01 | AC | 8 ms
6,816 KB |
testcase_02 | AC | 8 ms
6,820 KB |
testcase_03 | AC | 8 ms
6,816 KB |
testcase_04 | AC | 8 ms
6,820 KB |
testcase_05 | AC | 8 ms
6,820 KB |
testcase_06 | AC | 8 ms
6,824 KB |
testcase_07 | AC | 7 ms
6,816 KB |
testcase_08 | AC | 7 ms
6,820 KB |
testcase_09 | AC | 7 ms
6,816 KB |
testcase_10 | AC | 7 ms
6,816 KB |
testcase_11 | AC | 7 ms
6,820 KB |
testcase_12 | AC | 6 ms
6,816 KB |
testcase_13 | AC | 7 ms
6,820 KB |
testcase_14 | AC | 7 ms
6,820 KB |
testcase_15 | AC | 7 ms
6,816 KB |
testcase_16 | AC | 7 ms
6,816 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:42:15: 37 | do i=2,size(dp) | 2 ...... 42 | 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:42:22: 42 | 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))) end do dp(i)=flag end do read*,n if(dp(n))then print'("Win")' else print'("Lose")' end if end program main