Skip to content

Commit 7073993

Browse files
committed
codeforces round 674 div 3 question A,B,C solution added
1 parent 6b3c6b2 commit 7073993

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int t, n, x, f;
8+
cin >> t;
9+
while (t--)
10+
{
11+
cin >> n >> x;
12+
if (n == 1 || n == 2)
13+
f = 1;
14+
else
15+
{
16+
for (int i = 2, j = 2;; i += x, j++)
17+
{
18+
if (n > i && n <= i + x)
19+
{
20+
f = j;
21+
break;
22+
}
23+
}
24+
}
25+
cout << f << "\n";
26+
}
27+
return 0;
28+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int t, n, m;
8+
cin >> t;
9+
string s = "NO";
10+
while (t--)
11+
{
12+
cin >> n >> m;
13+
int count = 0;
14+
int a, b, c, d;
15+
for (int i = 0; i < n; i++)
16+
{
17+
cin >> a >> b;
18+
cin >> c >> d;
19+
if (b == c)
20+
count++;
21+
}
22+
if (count > 0 && m % 2 == 0)
23+
s = "YES";
24+
else
25+
{
26+
s = "NO";
27+
}
28+
29+
cout << s << "\n";
30+
}
31+
return 0;
32+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int t, n, rn;
8+
cin >> t;
9+
while (t--)
10+
{
11+
cin >> n;
12+
int rn = sqrt(n);
13+
if (n % rn == 0)
14+
{
15+
cout << (n / rn) + rn - 2 << "\n";
16+
}
17+
else
18+
{
19+
cout << (n / rn) + rn - 1 << "\n";
20+
}
21+
}
22+
return 0;
23+
}

0 commit comments

Comments
 (0)