Skip to content

Commit 8cf50ab

Browse files
committed
done
1 parent 108ee84 commit 8cf50ab

File tree

5 files changed

+20
-107
lines changed

5 files changed

+20
-107
lines changed

CF1.cpp

Lines changed: 17 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,6 @@ using namespace std;
1616
using i64 = long long;
1717
using u64 = unsigned long long;
1818
using u32 = unsigned;
19-
string updateString(string S,
20-
string A, string B)
21-
{ int l = A.length();
22-
for (int i = 0; i + l <= S.length(); i++)
23-
{
24-
string curr = S.substr(i, i + l);
25-
if (curr == A)
26-
{
27-
string new_string = "";
28-
new_string += S.substr(0, i) + B +
29-
S.substr(i + l, S.length());
30-
S = new_string;
31-
i += l - 1;
32-
}
33-
else
34-
{
35-
string new_string = "";
36-
new_string += S.substr(0, i) + A +
37-
S.substr(i + l, S.length());
38-
S = new_string;
39-
i += l - 1;
40-
}
41-
}
42-
return S;
43-
}
4419
int main() {
4520
FIO;
4621
#ifndef ONLINE_JUDGE
@@ -49,44 +24,24 @@ int main() {
4924
#endif
5025
int tc;
5126
cin >> tc;
27+
map<string,int> mp;
5228
while (tc--) {
53-
int n;
54-
cin >> n;
55-
string s;
56-
cin>>s;
57-
char c;
58-
cout<<"1";
59-
if(s[0]=='0')
60-
c='1';
61-
else
62-
c='2';
63-
for(int i=1;i<n;i++){
64-
if(s[i]=='1'){
65-
if(c=='2'){
66-
cout<<'0';
67-
c='1';
68-
}
69-
else{
70-
cout<<'1';
71-
c='2';
72-
}
73-
}
74-
else{
75-
if(c=='2'){
76-
cout<<'1';
77-
c='1';
78-
}
79-
else if(c=='1'){
80-
cout<<'0';
81-
c='0';
82-
}
83-
else{
84-
cout<<'1';
85-
c='1';
86-
}
87-
}
29+
int n,l;
30+
cin>>n>>l;
31+
set<int> s;
32+
for(int i=0;i<n;i++){
33+
int x;
34+
cin>>x;
35+
s.insert(x);
36+
}
37+
double maxm=0;
38+
int curr=0;
39+
for(auto i:s){
40+
maxm=max((double)(i-curr)/2,maxm);
41+
curr=i;
8842
}
89-
cout<<endl;
90-
43+
maxm=max(maxm,l-curr);
44+
maxm=max(maxm,*s.begin());
45+
cout<<fixed<<setprecision(10)<<maxm<<endl;
9146
}
9247
}

CF1.exe

38 KB
Binary file not shown.

CF2.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,6 @@ using namespace std;
1616
using i64 = long long;
1717
using u64 = unsigned long long;
1818
using u32 = unsigned;
19-
bool isPrime(int n)
20-
{
21-
if (n <= 1) return false;
22-
if (n <= 3) return true;
23-
if (n%2 == 0 || n%3 == 0) return false;
24-
25-
for (int i=5; i*i<=n; i=i+6)
26-
if (n%i == 0 || n%(i+2) == 0)
27-
return false;
28-
29-
return true;
30-
}
31-
int nextPrime(int N)
32-
{
33-
if (N <= 1)
34-
return 2;
35-
int prime = N;
36-
bool found = false;
37-
while (!found) {
38-
prime++;
39-
40-
if (isPrime(prime))
41-
found = true;
42-
}
43-
return prime;
44-
}
4519
int main() {
4620
FIO;
4721
#ifndef ONLINE_JUDGE
@@ -53,8 +27,5 @@ int main() {
5327
while (tc--) {
5428
int n;
5529
cin >> n;
56-
int a=nextPrime(1+n);
57-
int b=nextPrime(a+n);
58-
cout<<a*b<<endl;
5930
}
6031
}

input.txt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
1-
5
2-
1
3-
0
4-
3
5-
011
6-
3
7-
110
8-
6
9-
111000
10-
6
11-
001011
1+
1 7 15
2+
15 5 3 7 9 14 0

output.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
1
2-
110
3-
100
4-
101101
5-
101110
1+
2.5000000000

0 commit comments

Comments
 (0)