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 92212ec

Browse files
Added more stuff
1 parent 22af7d0 commit 92212ec

File tree

7 files changed

+263
-2
lines changed

7 files changed

+263
-2
lines changed

‎Number Theory/Test.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3

‎Number Theory/a.out‎

19.5 KB
Binary file not shown.

‎Number Theory/prime.cpp‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
3+
Name: Mehul Chaturvedi
4+
IIT-Guwahati
5+
6+
*/
7+
8+
/*
9+
PROBLEM STATEMENT
10+
11+
*/
12+
13+
#include <bits/stdc++.h>
14+
using namespace std;
15+
16+
typedef long long ll;
17+
typedef unordered_map<int, int> umapii;
18+
typedef unordered_map<int, bool> umapib;
19+
typedef unordered_map<string, int> umapsi;
20+
typedef unordered_map<string, string> umapss;
21+
typedef map<string, int> mapsi;
22+
typedef map<pair<int, int>, int> mappiii;
23+
typedef map<int, int> mapii;
24+
typedef pair<int, int> pii;
25+
typedef pair<long long, long long> pll;
26+
typedef unordered_set<int> useti;
27+
28+
#define uset unordered_set
29+
#define it iterator
30+
#define mp make_pair
31+
#define pb push_back
32+
#define all(x) (x).begin(), (x).end()
33+
#define f first
34+
#define s second
35+
#define MOD 1000000007
36+
37+
38+
int main( int argc , char ** argv )
39+
{
40+
ios_base::sync_with_stdio(false) ;
41+
cin.tie(NULL) ;
42+
43+
int n;
44+
cin>>n;
45+
int count = 0;
46+
47+
if (n>=2)
48+
{
49+
count++;
50+
}
51+
if (n>=3)
52+
{
53+
count++;
54+
}
55+
56+
//cout << n << '\n';
57+
for (int i = 2; i <= n; ++i)
58+
{
59+
int flag = 0;
60+
for (int j = 2; j*j <= i; ++j)
61+
{
62+
if (i%j==0)
63+
{
64+
flag = 0;
65+
break;
66+
}else{
67+
flag = 1;
68+
}
69+
70+
}
71+
if (flag == 1)
72+
{
73+
count++;
74+
}
75+
}
76+
77+
cout <<count<<endl;
78+
79+
80+
81+
return 0 ;
82+
83+
84+
85+
}
86+

‎String/Zalgo.cpp‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
3+
Name: Mehul Chaturvedi
4+
IIT-Guwahati
5+
6+
*/
7+
8+
/*
9+
PROBLEM STATEMENT
10+
11+
*/
12+
13+
#include <bits/stdc++.h>
14+
using namespace std;
15+
16+
typedef long long ll;
17+
typedef unordered_map<int, int> umapii;
18+
typedef unordered_map<int, bool> umapib;
19+
typedef unordered_map<string, int> umapsi;
20+
typedef unordered_map<string, string> umapss;
21+
typedef map<string, int> mapsi;
22+
typedef map<pair<int, int>, int> mappiii;
23+
typedef map<int, int> mapii;
24+
typedef pair<int, int> pii;
25+
typedef pair<long long, long long> pll;
26+
typedef unordered_set<int> useti;
27+
28+
#define uset unordered_set
29+
#define it iterator
30+
#define mp make_pair
31+
#define pb push_back
32+
#define all(x) (x).begin(), (x).end()
33+
#define f first
34+
#define s second
35+
#define MOD 1000000007
36+
37+
38+
int main( int argc , char ** argv )
39+
{
40+
ios_base::sync_with_stdio(false) ;
41+
cin.tie(NULL) ;
42+
43+
44+
45+
46+
47+
48+
return 0 ;
49+
50+
51+
52+
}
53+

‎String/a.out‎

38.5 KB
Binary file not shown.

‎String/input.txt‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
Hello I am Shreyashish Sengupta
2-
Shreyashish
1+
aaaa

‎String/palindromecount.cpp‎

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
3+
Name: Mehul Chaturvedi
4+
IIT-Guwahati
5+
6+
*/
7+
8+
/*
9+
PROBLEM STATEMENT
10+
Given a string S, count and return the number of substrings of S that are palindrome.
11+
Single length substrings are also palindromes. You just need to calculate the count, not the substrings.
12+
Input Format :
13+
String S
14+
Output Format :
15+
count of palindrome substrings
16+
Constraints :
17+
1 <= Length of S <= 1000
18+
Sample Input :
19+
aba
20+
Sample Output :
21+
4
22+
**Note : Here 4 corresponds to ("a","b","a","aba").
23+
*/
24+
25+
#include <bits/stdc++.h>
26+
using namespace std;
27+
28+
typedef long long ll;
29+
typedef unordered_map<int, int> umapii;
30+
typedef unordered_map<int, bool> umapib;
31+
typedef unordered_map<string, int> umapsi;
32+
typedef unordered_map<string, string> umapss;
33+
typedef map<string, int> mapsi;
34+
typedef map<pair<int, int>, int> mappiii;
35+
typedef map<int, int> mapii;
36+
typedef pair<int, int> pii;
37+
typedef pair<long long, long long> pll;
38+
typedef unordered_set<int> useti;
39+
40+
#define uset unordered_set
41+
#define it iterator
42+
#define mp make_pair
43+
#define pb push_back
44+
#define all(x) (x).begin(), (x).end()
45+
#define f first
46+
#define s second
47+
#define MOD 1000000007
48+
49+
int countPalindromes(string s)
50+
{
51+
int count = 0;
52+
unordered_map<string, int> m;
53+
for (int i = 0; i < s.length(); i++) {
54+
55+
// check for odd length palindromes
56+
for (int j = 0; j <= i; j++) {
57+
58+
if (!s[i + j])
59+
break;
60+
61+
if (s[i - j] == s[i + j]) {
62+
63+
// check for palindromes of length
64+
// greater than 1
65+
if ((i + j + 1) - (i - j) > 1){
66+
m[s.substr(i - j,
67+
(i + j + 1) - (i - j))]++;
68+
count++;
69+
}
70+
71+
} else
72+
break;
73+
}
74+
75+
// check for even length palindromes
76+
for (int j = 0; j <= i; j++) {
77+
if (!s[i + j + 1])
78+
break;
79+
if (s[i - j] == s[i + j + 1]) {
80+
81+
// check for palindromes of length
82+
// greater than 1
83+
if ((i + j + 2) - (i - j) > 1)
84+
m[s.substr(i - j,
85+
(i + j + 2) - (i - j))]++;
86+
count++;
87+
88+
} else
89+
break;
90+
}
91+
}
92+
return count;
93+
}
94+
int countPalindromeSubstrings(char s[]) {
95+
string str;
96+
for (int i = 0; s[i]!='0円'; ++i)
97+
{
98+
str += s[i];
99+
}
100+
101+
return countPalindromes(str)+str.size();
102+
103+
}
104+
int main( int argc , char ** argv )
105+
{
106+
ios_base::sync_with_stdio(false) ;
107+
cin.tie(NULL) ;
108+
109+
char input[10000];
110+
cin >> input;
111+
cout << countPalindromeSubstrings(input) << endl;
112+
113+
114+
115+
116+
117+
return 0 ;
118+
119+
120+
121+
}
122+

0 commit comments

Comments
(0)

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