Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bab9c81

Browse files
Merge pull request #148 from ishan-nahid/ccf
added code with right naming convension
2 parents 0dc0e41 + d7419e7 commit bab9c81

File tree

6 files changed

+327
-0
lines changed

6 files changed

+327
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
#define ll long long
5+
#define pb(x) push_back(x)
6+
7+
void setup();
8+
void solve();
9+
10+
int main()
11+
{
12+
setup();
13+
solve();
14+
return 0;
15+
}
16+
17+
void solve()
18+
{
19+
ll t;
20+
cin >> t;
21+
while(t--)
22+
{
23+
ll a, b;
24+
cin >> a >> b;
25+
26+
if(b-a == 1 || b-a == 3) cout << "YES" << endl;
27+
else if(b-a == 2) cout << "NO" << endl;
28+
else
29+
{
30+
if((b-a)%3 == 0 || (b-a)%3 == 1) cout << "YES" << endl;
31+
else cout << "NO" << endl;
32+
// if(a%2 == 0 && b%2 == 0)
33+
// else if(a%2 != 0 && b%2 != 0)
34+
// else if(a%2 == 0 && b%2 != 0)
35+
// else if(a%2 != 0 && b%2 == 0)
36+
}
37+
}
38+
}
39+
void setup()
40+
{
41+
ios::sync_with_stdio(false);
42+
cin.tie(NULL);
43+
cout.tie(NULL);
44+
#ifndef ONLINE_JUDGE
45+
freopen("input.txt", "r", stdin);
46+
freopen("output.txt", "w", stdout);
47+
#else
48+
#endif
49+
}
50+
51+
// 2 -> 3, 5, 6, 8, 9, 11, 12
52+
// 3 -> 4, (6, 7,) (9, 10,) (12, 13)
53+
// 4 -> 5, 7, 8, 10, 11, 13, 14
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
#define ll long long
5+
#define pb(x) push_back(x)
6+
7+
void setup();
8+
void solve();
9+
10+
int main()
11+
{
12+
setup();
13+
solve();
14+
return 0;
15+
}
16+
17+
void solve()
18+
{
19+
ll t, x, y;
20+
cin >> t;
21+
22+
while(t--)
23+
{
24+
cin >> x >> y;
25+
if(x > y) cout << (x-y) << endl;
26+
else cout << 0 << endl;
27+
}
28+
}
29+
void setup()
30+
{
31+
ios::sync_with_stdio(false);
32+
cin.tie(NULL);
33+
cout.tie(NULL);
34+
#ifndef ONLINE_JUDGE
35+
freopen("input.txt", "r", stdin);
36+
freopen("output.txt", "w", stdout);
37+
#else
38+
#endif
39+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#include <bits/stdc++.h>
2+
#include <math.h>
3+
using namespace std;
4+
5+
#define ll long long
6+
#define pb(x) push_back(x)
7+
8+
void setup();
9+
void solve();
10+
11+
int main()
12+
{
13+
setup();
14+
solve();
15+
return 0;
16+
}
17+
18+
void solve()
19+
{
20+
ll t;
21+
cin >> t;
22+
while(t--)
23+
{
24+
ll n;
25+
string s1, s2;
26+
27+
cin >> n >> s1 >> s2;
28+
29+
ll ss1 = s1.size(), ss2 = s2.size();
30+
31+
set <char> s;
32+
ll c = 0;
33+
for(ll i = 0; i < ss1; i++)
34+
{
35+
if(s1[i] != s2[i])
36+
{
37+
c++;
38+
s.insert(s2[i]);
39+
}
40+
}
41+
42+
// cout << c << " " << s.size() << endl;
43+
// for (auto itr : s)
44+
// {
45+
// cout << itr << " ";
46+
// }
47+
// cout << endl;
48+
if(c > s.size()) cout << s.size() << endl;
49+
else cout << c << endl;
50+
51+
}
52+
}
53+
void setup()
54+
{
55+
ios::sync_with_stdio(false);
56+
cin.tie(NULL);
57+
cout.tie(NULL);
58+
#ifndef ONLINE_JUDGE
59+
freopen("input.txt", "r", stdin);
60+
freopen("output.txt", "w", stdout);
61+
#else
62+
#endif
63+
}
64+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
5+
#define ll long long
6+
#define frp(a, b) for(ll i = a; i < b; i++)
7+
#define frn(a, b) for(ll i = a; i > b; i--)
8+
9+
#define in(x) insert(x)
10+
#define pb(x) push_back(x)
11+
#define full(x) x.begin(),x.end()
12+
13+
ll gcd(ll a, ll b);
14+
void setup();
15+
void solve();
16+
17+
int main()
18+
{
19+
setup();
20+
solve();
21+
return 0;
22+
}
23+
24+
void solve()
25+
{
26+
ll T, N;
27+
cin >> T;
28+
while(T--)
29+
{
30+
cin >> N;
31+
32+
vector <ll> v(N);
33+
34+
frp(0, N) cin >> v[i];
35+
36+
sort(v.begin(), v.end());
37+
38+
ll g = v[0];
39+
40+
for(ll j = 1; j < N; j++) g = gcd(g, v[j]);
41+
42+
cout << g*N << endl;
43+
44+
}
45+
}
46+
47+
ll gcd(ll a, ll b)
48+
{
49+
if(a%b == 0) return b;
50+
else return gcd(b, a%b);
51+
}
52+
void setup()
53+
{
54+
ios::sync_with_stdio(false);
55+
cin.tie(NULL);
56+
cout.tie(NULL);
57+
#ifndef ONLINE_JUDGE
58+
freopen("input.txt", "r", stdin);
59+
freopen("one.txt", "w", stdout);
60+
#else
61+
#endif
62+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include <iostream>
2+
#include <cmath>
3+
#include <algorithm>
4+
5+
using namespace std;
6+
7+
void solve();
8+
9+
int main()
10+
{
11+
12+
solve();
13+
14+
return 0;
15+
}
16+
17+
void solve()
18+
{
19+
int t;
20+
string s;
21+
22+
cin >> t;
23+
24+
while(t--)
25+
{
26+
cin >> s;
27+
28+
int ss = s.size(), f = 0, c = 0;
29+
30+
for(int i = 0; i < ss; i++)
31+
{
32+
if(s[i] == 49)
33+
{
34+
c++;
35+
f = i;
36+
}
37+
}
38+
39+
if(c == 0)
40+
{
41+
cout << "NO" << endl;
42+
}
43+
else
44+
{
45+
for(int i = f; i >= 0; i--)
46+
{
47+
if(s[i] == 48)
48+
{
49+
break;
50+
}
51+
else
52+
{
53+
c--;
54+
}
55+
}
56+
57+
//cout << c << endl;
58+
if(c == 0)
59+
{
60+
cout << "YES" << endl;
61+
}
62+
else
63+
{
64+
cout << "NO" << endl;
65+
}
66+
}
67+
68+
}
69+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
#define ll long long
5+
#define pb(x) push_back(x)
6+
7+
void setup();
8+
void solve();
9+
10+
int main()
11+
{
12+
setup();
13+
solve();
14+
return 0;
15+
}
16+
17+
void solve()
18+
{
19+
ll t;
20+
cin >> t;
21+
while(t--)
22+
{
23+
ll n, x;
24+
cin >> n >> x;
25+
26+
if(n <= 6) cout << x << endl;
27+
else cout << int(ceil(n/6.0)*x) << endl;
28+
}
29+
}
30+
void setup()
31+
{
32+
ios::sync_with_stdio(false);
33+
cin.tie(NULL);
34+
cout.tie(NULL);
35+
#ifndef ONLINE_JUDGE
36+
freopen("input.txt", "r", stdin);
37+
freopen("output.txt", "w", stdout);
38+
#else
39+
#endif
40+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /