Submission #1532356
Source Code Expand
#include "bits/stdc++.h" #include<unordered_map> #include<unordered_set> #pragma warning(disable:4996) using namespace std; using ld = long double; const ld eps = 1e-9; vector<int>primes; void hurui(const int amax) { static bool flag = false; if (flag)return; vector<int>sos; sos = vector<int>(amax + 1, true); sos[0] = false; sos[1] = false; for (int i = 2; i <= amax; ++i) { if (sos[i]) { for (int j = 2 * i; j <= amax; j += i)sos[j] = false; } } for (int i = 0; i <= amax; ++i) { if (sos[i]) { primes.push_back(i); } } flag = true; } int main() { hurui(1e7); int N; cin >> N; if (N == 1) { cout << 3 << endl; } else { vector<int>as; for (int i = 0; i < N; ++i) { int a; cin >> a; as.emplace_back(a); } int ans = 0; int t = as.back() - as.front()+1; if (t % 2) { if (binary_search(primes.begin(), primes.end(), t)) { ans = 1; } else { ans = 3; } } else { ans = 2; } for (int i = 0; i < N - 1; ++i) { int k = as[i + 1] - as[i]-1; if (k % 2) { if (binary_search(primes.begin(), primes.end(), k)) { ans += 1; } else { ans += 3; } } else { if (k == 0)ans += 0; else ans += 2; } } cout << ans << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Prime Flip |
User | yuma000 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1324 Byte |
Status | WA |
Exec Time | 253 ms |
Memory | 45552 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1200 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt, 1_50.txt, 1_51.txt, 1_52.txt, 1_53.txt, 1_54.txt, 1_55.txt, 1_56.txt, 1_57.txt, 1_58.txt, 1_59.txt, 1_60.txt, 1_61.txt, 1_62.txt, 1_63.txt, 1_64.txt, 1_65.txt, 1_66.txt, 1_67.txt, 1_68.txt, 1_69.txt, 1_70.txt, 1_71.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 222 ms | 43888 KB |
0_01.txt | AC | 225 ms | 45552 KB |
0_02.txt | AC | 221 ms | 43504 KB |
1_00.txt | AC | 223 ms | 45552 KB |
1_01.txt | AC | 222 ms | 43760 KB |
1_02.txt | AC | 224 ms | 44016 KB |
1_03.txt | WA | 224 ms | 44528 KB |
1_04.txt | AC | 222 ms | 44144 KB |
1_05.txt | AC | 222 ms | 43760 KB |
1_06.txt | AC | 224 ms | 45296 KB |
1_07.txt | WA | 223 ms | 44784 KB |
1_08.txt | WA | 223 ms | 44784 KB |
1_09.txt | WA | 226 ms | 45296 KB |
1_10.txt | WA | 249 ms | 43632 KB |
1_11.txt | WA | 225 ms | 44144 KB |
1_12.txt | WA | 225 ms | 45168 KB |
1_13.txt | WA | 230 ms | 43632 KB |
1_14.txt | WA | 250 ms | 44272 KB |
1_15.txt | WA | 224 ms | 43760 KB |
1_16.txt | WA | 226 ms | 44400 KB |
1_17.txt | WA | 253 ms | 44656 KB |
1_18.txt | WA | 247 ms | 44400 KB |
1_19.txt | WA | 224 ms | 45040 KB |
1_20.txt | WA | 252 ms | 44656 KB |
1_21.txt | WA | 245 ms | 43504 KB |
1_22.txt | WA | 228 ms | 43888 KB |
1_23.txt | WA | 235 ms | 45168 KB |
1_24.txt | WA | 223 ms | 45424 KB |
1_25.txt | WA | 223 ms | 44912 KB |
1_26.txt | WA | 223 ms | 44400 KB |
1_27.txt | WA | 222 ms | 43632 KB |
1_28.txt | AC | 224 ms | 45040 KB |
1_29.txt | WA | 224 ms | 44016 KB |
1_30.txt | WA | 228 ms | 43760 KB |
1_31.txt | WA | 226 ms | 43760 KB |
1_32.txt | WA | 233 ms | 44528 KB |
1_33.txt | AC | 232 ms | 44016 KB |
1_34.txt | AC | 234 ms | 43504 KB |
1_35.txt | WA | 235 ms | 45296 KB |
1_36.txt | AC | 253 ms | 44656 KB |
1_37.txt | WA | 225 ms | 45040 KB |
1_38.txt | WA | 224 ms | 43760 KB |
1_39.txt | WA | 225 ms | 43888 KB |
1_40.txt | WA | 250 ms | 44016 KB |
1_41.txt | WA | 225 ms | 45296 KB |
1_42.txt | WA | 223 ms | 44528 KB |
1_43.txt | WA | 223 ms | 44656 KB |
1_44.txt | WA | 222 ms | 44272 KB |
1_45.txt | WA | 223 ms | 45040 KB |
1_46.txt | WA | 223 ms | 45296 KB |
1_47.txt | WA | 246 ms | 45168 KB |
1_48.txt | WA | 231 ms | 44016 KB |
1_49.txt | WA | 250 ms | 44912 KB |
1_50.txt | WA | 224 ms | 44272 KB |
1_51.txt | WA | 223 ms | 44656 KB |
1_52.txt | WA | 224 ms | 43632 KB |
1_53.txt | WA | 224 ms | 44016 KB |
1_54.txt | WA | 223 ms | 45168 KB |
1_55.txt | WA | 223 ms | 44272 KB |
1_56.txt | WA | 222 ms | 44400 KB |
1_57.txt | WA | 230 ms | 44144 KB |
1_58.txt | WA | 248 ms | 44400 KB |
1_59.txt | WA | 239 ms | 44784 KB |
1_60.txt | WA | 248 ms | 43888 KB |
1_61.txt | WA | 226 ms | 44784 KB |
1_62.txt | WA | 222 ms | 45296 KB |
1_63.txt | WA | 223 ms | 45168 KB |
1_64.txt | WA | 236 ms | 44784 KB |
1_65.txt | WA | 252 ms | 44016 KB |
1_66.txt | WA | 223 ms | 45424 KB |
1_67.txt | WA | 226 ms | 43632 KB |
1_68.txt | WA | 236 ms | 44528 KB |
1_69.txt | WA | 248 ms | 44144 KB |
1_70.txt | WA | 238 ms | 45040 KB |
1_71.txt | WA | 236 ms | 44912 KB |