· last year · Mar 26, 2024, 12:20 PM
1https://www.police.uk/tua/tell-us-about/ath/possible-terrorist-activity/report-possible-terrorist-activity2/report-possible-terrorist-activity/Complete?subid=321387d2-b8eb-418c-8038-42db6cc83c35
2Quickly exit this site by pressing the Escape key
3Leave this site
4Cookies
5Your cookie preferences have been saved. You can update your cookie settings at any time on the cookies page.
6
7Close
8Skip to main content
9
10Skip to main navigation
11
12Skip to form
13puk-logo
14Search this website
15Search
16Search
17
18Contact us
19Services and information
20Support
21Policing in the UK
22Performance
23Your area
24 Tell us about possible terrorist activity
25Report possible terrorist activity
26Complete
27Thank you
28We’ll review your report and get back to you if necessary.
29
30Your receipt code is below. Please keep it in case you need to contact us about this report again.
31
32ATH-3898-24-15000-000
33
34For security reasons we haven't emailed your report to you. To download a copy, please use the button below.
35
36 Download a copy
37
38More on this topic
39Terrorism in the UK
40Footer navigation
41Police.uk
42Contact us
43Find a police force
44Feedback about this website
45Cookies
46Terms and conditions
47Privacy
48Accessibility
49About the Open Government Licence
50Information and services
51Online services
52Careers and volunteering
53Crime prevention advice
54Data downloads and API
55Support
56Partners
57NPCC
58APCC
59Ask the police
60Ministry of Justice - Victim and Witness Information Service
61Victim Support
62Language
63Cymraeg
64© Copyright 2024. All content rights reserved.
65
66All data is available under the Open Government Licence v3.0 unless otherwise stated.
67
68
69
70log_duration.h
71
72#pragma once
73
74#include <chrono>
75#include <iostream>
76
77#define PROFILE_CONCAT_INTERNAL(X, Y) X##Y
78#define PROFILE_CONCAT(X, Y) PROFILE_CONCAT_INTERNAL(X, Y)
79#define UNIQUE_VAR_NAME_PROFILE PROFILE_CONCAT(profileGuard, __LINE__)
80#define LOG_DURATION(x) LogDuration UNIQUE_VAR_NAME_PROFILE(x)
81
82class LogDuration {
83public:
84 // заменим имя типа std::chrono::steady_clock
85 // с помощью using для удобства
86 using Clock = std::chrono::steady_clock;
87
88 LogDuration(const std::string& id) : id_(id) {
89 }
90
91 ~LogDuration() {
92 using namespace std::chrono;
93 using namespace std::literals;
94
95 const auto end_time = Clock::now();
96 const auto dur = end_time - start_time_;
97 std::cerr << id_ << ": "s << duration_cast<milliseconds>(dur).count() << " ms"s << std::endl;
98 }
99
100private:
101 const std::string id_;
102 const Clock::time_point start_time_ = Clock::now();
103};
104
105***************************************************************************************************************************************
106main.cpp
107
108#include <chrono>
109#include <cstdlib>
110#include <iostream>
111#include <vector>
112#include <algorithm>
113#include "log_duration.h"
114
115using namespace std;
116
117vector<int> ReverseVector(const std::vector<int>& source_vector) {
118 std::vector<int> res(source_vector.size());
119 std::reverse_copy(source_vector.begin(), source_vector.end(), res.begin());
120 return res;
121}
122
123int CountPops(const vector<int>& source_vector, int begin, int end) {
124 int res = 0;
125
126 for (int i = begin; i < end; ++i) {
127 if (source_vector[i]) {
128 ++res;
129 }
130 }
131
132 return res;
133}
134
135void AppendRandom(vector<int>& v, int n) {
136 v.reserve(n);
137 for (int i = 0; i < n; ++i) {
138 // получаем случайное число с помощью функции rand.
139 // с помощью (rand() % 2) получим целое число в диапазоне 0..1.
140 // в C++ имеются более современные генераторы случайных чисел,
141 // но в данном уроке не будем их касаться
142 v.push_back(rand() % 2);
143 }
144}
145
146void Operate() {
147 {
148 LOG_DURATION("Total");
149
150 vector<int> random_bits;
151
152 // операция << для целых чисел это сдвиг всех бит в двоичной
153 // записи числа. Запишем с её помощью число 2 в степени 17 (131072)
154 static const int N = 1 << 17;
155
156 // заполним вектор случайными числами 0 и 1
157 {
158 LOG_DURATION("Append random");
159 AppendRandom(random_bits, N);
160 }
161
162 vector<int> reversed_bits;
163 // перевернём вектор задом наперёд
164 {
165 LOG_DURATION("Reverse");
166 reversed_bits = ReverseVector(random_bits);
167 }
168
169 {
170 LOG_DURATION("Counting");
171 for (int i = 1, step = 1; i <= N; i += step, step *= 2) {
172 double rate = CountPops(reversed_bits, 0, i) * 100. / i;
173 cout << "After "s << i << " bits we found "s << rate << "% pops"s << endl;
174 }
175 }
176 }
177}
178
179int main() {
180 Operate();
181}