forked from harrypotter0/algorithms-in-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f8a520
commit 4f4f6cf
Showing
6 changed files
with
180 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
//CODE BY AKASH KANDPAL | ||
int main() | ||
{ | ||
int t; | ||
cin>>t; | ||
while(t--) | ||
{ | ||
int n,m; | ||
cin>>n>>m; | ||
char arr[n][m]; | ||
int i,j; | ||
for(i=0;i<n;i++) | ||
{ | ||
for(j=0;j<m;j++) | ||
{ | ||
//fflush(stdin); | ||
cin>>arr[i][j]; | ||
} | ||
} | ||
int cnt=1,ans=0; | ||
for(i=0;i<n;i++) | ||
{ | ||
cnt=1; | ||
for(j=1;j<m;j++) | ||
{ | ||
if(arr[i][j]==arr[i][j-1]) | ||
cnt++; | ||
else | ||
cnt=1; | ||
ans=max(ans,cnt); | ||
} | ||
} | ||
for(i=0;i<m;i++) | ||
{ | ||
cnt=1; | ||
for(j=1;j<n;j++) | ||
{ | ||
if(arr[j][i]==arr[j-1][i]) | ||
cnt++; | ||
else | ||
cnt=1; | ||
ans=max(ans,cnt); | ||
|
||
} | ||
} | ||
cout<<ans<<endl; | ||
} | ||
return 0; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
T = int(input()) | ||
for t in range(T): | ||
N = int(input()) | ||
if N % 9 == 2 or N % 9 == 3: | ||
print('Sailaja') | ||
else: | ||
print('Supraja') | ||
|
||
''' | ||
Input: | ||
5 | ||
Output: | ||
Supraja | ||
Sample - 2 | ||
Input: | ||
3 | ||
Output: | ||
Sailaja | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
typedef unsigned long long int ll; | ||
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);} | ||
int main() | ||
{ | ||
ll t; | ||
cin>>t; | ||
while(t--) | ||
{ | ||
ll n,d=0; | ||
cin>>n; | ||
while(n) | ||
{ | ||
if(!(n&1)) | ||
d++; | ||
n=n>>1; | ||
} | ||
ll xx=pow(2,d); | ||
cout<<xx<<endl; | ||
} | ||
} | ||
|
||
|
||
/* | ||
Example-1 | ||
Input: | ||
1 | ||
5 | ||
Output: | ||
2 | ||
Example-2 | ||
Input: | ||
1 | ||
10 | ||
Output: | ||
4 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <iostream> | ||
using namespace std; | ||
int sum =0 ; | ||
int fun(int n, int k) | ||
{ | ||
// cout<<sum; | ||
if (n == 1)return 1; | ||
else | ||
return (fun(n - 1, k) + k - 1) % n + 1; | ||
} | ||
int saveMary(int n, int k){ | ||
if (n<=0 || k<=0)return -1; | ||
else return fun(n, k); | ||
} | ||
int main() | ||
{ | ||
int n,t,k; | ||
cin>>t; | ||
while(t--) | ||
{ | ||
cin>>n>>k; | ||
cout<<saveMary(n, k)<<endl; | ||
// cout<<sum; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import math | ||
def readInts(): | ||
return list(map(int, raw_input().strip().split())) | ||
def readInt(): | ||
return int(raw_input()) | ||
def readIntsindex0(): | ||
return list(map(lambda x: int(x) - 1, input().split())) | ||
def readStrs(): | ||
return raw_input().split() | ||
def readStr(): | ||
return raw_input() | ||
|
||
|
||
for __ in range(readInt()): | ||
a,b = readInts() | ||
|
||
|
||
|
||
|
||
''' | ||
Sample Input 0 | ||
3 | ||
104 200 | ||
370 420 | ||
20 50 | ||
Sample Output 0 | ||
4 | ||
0 | ||
-1 | ||
''' |