結果
問題 | No.732 3PrimeCounting |
ユーザー | ohreitetsu |
提出日時 | 2018-09-07 23:06:56 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,002 bytes |
コンパイル時間 | 795 ms |
コンパイル使用メモリ | 86,164 KB |
実行使用メモリ | 9,000 KB |
最終ジャッジ日時 | 2023-08-19 22:25:15 |
合計ジャッジ時間 | 27,963 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
9,000 KB |
testcase_01 | AC | 32 ms
4,600 KB |
testcase_02 | AC | 32 ms
4,468 KB |
testcase_03 | AC | 33 ms
4,556 KB |
testcase_04 | AC | 32 ms
4,480 KB |
testcase_05 | AC | 32 ms
4,728 KB |
testcase_06 | AC | 32 ms
4,468 KB |
testcase_07 | AC | 32 ms
4,776 KB |
testcase_08 | AC | 32 ms
4,680 KB |
testcase_09 | AC | 32 ms
4,476 KB |
testcase_10 | AC | 32 ms
4,468 KB |
testcase_11 | AC | 32 ms
4,548 KB |
testcase_12 | AC | 32 ms
4,656 KB |
testcase_13 | AC | 32 ms
4,604 KB |
testcase_14 | AC | 32 ms
4,592 KB |
testcase_15 | AC | 32 ms
4,600 KB |
testcase_16 | AC | 32 ms
4,716 KB |
testcase_17 | AC | 32 ms
4,616 KB |
testcase_18 | AC | 32 ms
4,676 KB |
testcase_19 | AC | 32 ms
4,560 KB |
testcase_20 | AC | 42 ms
4,676 KB |
testcase_21 | AC | 418 ms
4,484 KB |
testcase_22 | AC | 417 ms
4,656 KB |
testcase_23 | AC | 33 ms
4,580 KB |
testcase_24 | AC | 33 ms
4,532 KB |
testcase_25 | AC | 2,255 ms
4,684 KB |
testcase_26 | AC | 927 ms
4,788 KB |
testcase_27 | AC | 60 ms
4,536 KB |
testcase_28 | AC | 61 ms
4,480 KB |
testcase_29 | AC | 240 ms
4,680 KB |
testcase_30 | AC | 240 ms
4,728 KB |
testcase_31 | AC | 514 ms
4,784 KB |
testcase_32 | AC | 1,282 ms
4,628 KB |
testcase_33 | AC | 1,308 ms
4,536 KB |
testcase_34 | AC | 1,315 ms
4,580 KB |
testcase_35 | AC | 669 ms
4,628 KB |
testcase_36 | AC | 670 ms
4,584 KB |
testcase_37 | AC | 35 ms
4,476 KB |
testcase_38 | AC | 35 ms
4,620 KB |
testcase_39 | AC | 750 ms
4,656 KB |
testcase_40 | AC | 570 ms
4,788 KB |
testcase_41 | AC | 573 ms
4,576 KB |
testcase_42 | AC | 575 ms
4,504 KB |
testcase_43 | AC | 315 ms
4,476 KB |
testcase_44 | AC | 318 ms
4,672 KB |
testcase_45 | AC | 83 ms
4,592 KB |
testcase_46 | AC | 82 ms
4,496 KB |
testcase_47 | AC | 134 ms
4,780 KB |
testcase_48 | AC | 2,720 ms
4,500 KB |
testcase_49 | AC | 2,721 ms
4,632 KB |
testcase_50 | AC | 433 ms
4,624 KB |
testcase_51 | AC | 450 ms
4,564 KB |
testcase_52 | AC | 72 ms
4,532 KB |
testcase_53 | TLE | - |
testcase_54 | -- | - |
testcase_55 | -- | - |
testcase_56 | -- | - |
testcase_57 | -- | - |
testcase_58 | -- | - |
testcase_59 | -- | - |
testcase_60 | -- | - |
testcase_61 | -- | - |
testcase_62 | -- | - |
testcase_63 | -- | - |
testcase_64 | -- | - |
testcase_65 | -- | - |
testcase_66 | -- | - |
testcase_67 | -- | - |
testcase_68 | -- | - |
testcase_69 | -- | - |
testcase_70 | -- | - |
testcase_71 | -- | - |
testcase_72 | -- | - |
testcase_73 | -- | - |
testcase_74 | -- | - |
testcase_75 | -- | - |
testcase_76 | -- | - |
testcase_77 | -- | - |
testcase_78 | -- | - |
testcase_79 | -- | - |
testcase_80 | -- | - |
testcase_81 | -- | - |
testcase_82 | -- | - |
testcase_83 | -- | - |
testcase_84 | -- | - |
testcase_85 | -- | - |
testcase_86 | -- | - |
testcase_87 | -- | - |
testcase_88 | -- | - |
ソースコード
#include <iostream> #include <math.h> #include <vector> #include <map> using namespace std; typedef long long LL; int IsPrime (int n) { int i; if (n < 2){ return 0; }else if (n == 2){ return 1; } if (n % 2 == 0){ return 0; } double sqrtNum = sqrt((double)n); for (i = 3; i <= sqrtNum; i += 2){ if (n % i == 0 ){ return 0; } } return 1; } int main(int argc, char* argv[]) { int N; cin>>N; int i,j,k; LL ans=0; map<int,int> myMap; map<int,int>::iterator mit; for (i=3;i<=300000;i+=2){ if (IsPrime(i)){ myMap[i]=1; } } vector<int> Prime; for (i=3;i<=N;i+=2){ mit=myMap.find(i); if (mit!=myMap.end()){ Prime.push_back(i); } } int PrimeNum=Prime.size(); for (i=0;i<PrimeNum-2;i++){ for (j=i+1;j<PrimeNum-1;j++){ for (k=j+1;k<PrimeNum;k++){ int x=Prime[i]+Prime[j]+Prime[k]; if (x%2==1){ mit=myMap.find(x); if (mit!=myMap.end()){ ans++; } } } } } cout<<ans<<endl; return 0; }