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
979b4b8
commit a078283
Showing
7 changed files
with
148 additions
and
12 deletions.
There are no files selected for viewing
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,37 @@ | ||
def readInts(): | ||
return map(int, raw_input().split()) | ||
def readInt(): | ||
return int(input()) | ||
|
||
for __ in range(readInt()): | ||
arr = readInts() | ||
c = 0 | ||
for i in arr: | ||
if i==1: | ||
c+=1 | ||
if(c==0): | ||
print("Beginner") | ||
elif(c==1): | ||
print("Junior Developer") | ||
elif(c==2): | ||
print("Middle Developer") | ||
elif(c==3): | ||
print("Senior Developer") | ||
elif(c==4): | ||
print("Hacker") | ||
else: | ||
print("Jeff Dean") | ||
|
||
|
||
''' | ||
7 | ||
0 0 0 0 0 | ||
0 1 0 1 0 | ||
0 0 1 0 0 | ||
1 1 1 1 1 | ||
0 1 1 1 0 | ||
0 1 1 1 1 | ||
1 1 1 1 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,58 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
/* O(sqrt(N)). */ | ||
vector<int> divisors(int n){ | ||
vector<int> d; | ||
int i; | ||
|
||
// For every i up to sqrt(n). | ||
for (i = 1; i * i <= n; i++){ | ||
// If i divides n. | ||
if (n % i == 0){ | ||
if (i * i == n){ | ||
// Pushing i. | ||
d.push_back(i); | ||
} | ||
else{ | ||
// Pushing i and n / i. | ||
d.push_back(i); | ||
d.push_back(n / i); | ||
} | ||
} | ||
} | ||
return d; | ||
} | ||
|
||
|
||
int main(){ | ||
int t, n, ans, a, b, c, i, j, x, y, z; | ||
vector<int> dx, dy; | ||
|
||
scanf("%d", &t); | ||
|
||
while (t--){ | ||
scanf("%d%d%d%d", &n, &a, &b, &c); | ||
|
||
dx = divisors(n); | ||
ans = 0; | ||
|
||
for (i = 0; i < (int)dx.size(); i++){ | ||
x = dx[i]; | ||
|
||
dy = divisors(n / x); | ||
|
||
for (j = 0; j < (int)dy.size(); j++){ | ||
y = dy[j]; | ||
z = n / (x * y); | ||
|
||
if (x <= a and y <= b and z <= c){ | ||
ans++; | ||
} | ||
} | ||
} | ||
printf("%d\n", ans); | ||
} | ||
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,7 @@ | ||
def readInts(): | ||
return map(int, raw_input().split()) | ||
def readInt(): | ||
return int(input()) | ||
|
||
for __ in range(readInt()): | ||
arr = readInts() |
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,19 @@ | ||
import math | ||
|
||
t = input() | ||
while t>0: | ||
t = t-1 | ||
s = raw_input() | ||
d = {} | ||
for i in range(len(s)): | ||
if s[i] not in d.keys(): | ||
d[s[i]] = 1 | ||
else: | ||
d[s[i]] += 1 | ||
ans = math.factorial(len(s)) | ||
# print(ans) | ||
for i in d.keys(): | ||
p = math.factorial(d[i]) | ||
ans /= p | ||
# print(p) | ||
print ans |
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,27 @@ | ||
def readInts(): | ||
return map(int, raw_input().split()) | ||
def readInt(): | ||
return int(input()) | ||
|
||
for __ in range(readInt()): | ||
r,b,m = readInts() | ||
ans = 0 | ||
for i in range(m+1): | ||
j = m-i | ||
# print(i,j,r,b) | ||
if i>r or j>b: | ||
continue | ||
ans+=1 | ||
print ans | ||
|
||
''' | ||
Input: | ||
2 | ||
1 1 2 | ||
3 2 2 | ||
Output: | ||
1 | ||
3 | ||
''' |
Empty file.