結果
問題 | No.843 Triple Primes |
ユーザー | ttttan2 |
提出日時 | 2019-06-28 21:43:39 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 418 ms / 2,000 ms |
コード長 | 1,123 bytes |
コンパイル時間 | 2,486 ms |
コンパイル使用メモリ | 168,956 KB |
実行使用メモリ | 20,940 KB |
最終ジャッジ日時 | 2023-10-19 17:39:34 |
合計ジャッジ時間 | 13,187 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 417 ms
20,940 KB |
testcase_02 | AC | 24 ms
8,312 KB |
testcase_03 | AC | 19 ms
7,332 KB |
testcase_04 | AC | 32 ms
9,692 KB |
testcase_05 | AC | 21 ms
7,696 KB |
testcase_06 | AC | 34 ms
10,004 KB |
testcase_07 | AC | 353 ms
20,484 KB |
testcase_08 | AC | 380 ms
20,656 KB |
testcase_09 | AC | 418 ms
20,928 KB |
testcase_10 | AC | 373 ms
20,556 KB |
testcase_11 | AC | 383 ms
20,748 KB |
testcase_12 | AC | 402 ms
20,876 KB |
testcase_13 | AC | 396 ms
20,816 KB |
testcase_14 | AC | 387 ms
20,816 KB |
testcase_15 | AC | 352 ms
20,516 KB |
testcase_16 | AC | 347 ms
20,540 KB |
testcase_17 | AC | 1 ms
4,348 KB |
testcase_18 | AC | 1 ms
4,348 KB |
testcase_19 | AC | 1 ms
4,348 KB |
testcase_20 | AC | 170 ms
18,900 KB |
testcase_21 | AC | 115 ms
17,656 KB |
testcase_22 | AC | 263 ms
19,884 KB |
testcase_23 | AC | 268 ms
19,944 KB |
testcase_24 | AC | 178 ms
18,992 KB |
testcase_25 | AC | 149 ms
18,528 KB |
testcase_26 | AC | 410 ms
20,920 KB |
testcase_27 | AC | 65 ms
14,296 KB |
testcase_28 | AC | 402 ms
20,836 KB |
testcase_29 | AC | 185 ms
19,096 KB |
testcase_30 | AC | 415 ms
20,892 KB |
testcase_31 | AC | 86 ms
16,128 KB |
testcase_32 | AC | 59 ms
13,744 KB |
testcase_33 | AC | 195 ms
19,236 KB |
testcase_34 | AC | 248 ms
19,764 KB |
testcase_35 | AC | 415 ms
20,932 KB |
testcase_36 | AC | 140 ms
18,296 KB |
testcase_37 | AC | 355 ms
20,412 KB |
testcase_38 | AC | 301 ms
20,124 KB |
testcase_39 | AC | 412 ms
20,856 KB |
testcase_40 | AC | 2 ms
4,348 KB |
testcase_41 | AC | 1 ms
4,348 KB |
testcase_42 | AC | 377 ms
20,600 KB |
testcase_43 | AC | 389 ms
20,748 KB |
ソースコード
#include<bits/stdc++.h> //ios::sync_with_stdio(false); //cin.tie(0); using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<pii,int> ppii; typedef pair<int,pii> pipi; typedef pair<ll,ll> pll; typedef pair<pll,ll> plpl; typedef tuple<ll,ll,ll> tl; ll mod=1000000007; ll mod2=998244353; ll inf=1000000000000000000; double pi=2*acos(0); #define rep(i,m,n) for(int i=m;i<n;i++) #define rrep(i,n,m) for(int i=n;i>=m;i--) ll lmax(ll a,ll b){ if(a<b)return b; else return a; } ll lmin(ll a,ll b){ if(a<b)return a; else return b; } int main(){ ios::sync_with_stdio(false); cin.tie(0); vector<int> pri; int n;cin>>n; bool used[n+1]; fill(used,used+n+1,false); map<int,int> mp; rep(i,2,n+1){ if(used[i])continue; pri.push_back(i); mp[i]++; for(int j=i;j<=n;j+=i)used[j]=true; } ll ans=0; rep(i,0,pri.size()){ if(pri[i]>1000)break; rep(j,0,pri.size()){ int now=pri[i]*pri[i]-pri[j]; if(now<=0)break; if(mp[now])ans++; } } cout<<ans<<endl; }