-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding some problems from cses and codeforces
- Loading branch information
1 parent
4ef182a
commit 15a78e7
Showing
3 changed files
with
107 additions
and
0 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,27 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
typedef unsigned long long ull; | ||
|
||
int checkLuckyNumber(string n) { | ||
|
||
ull count = 0; | ||
|
||
for(ull i = 0; n[i] != '\0'; ++i) { | ||
if(n[i] == '7' || n[i] == '4') | ||
count++; | ||
} | ||
|
||
if(count == 7 || count == 4) | ||
return 1; | ||
else | ||
return 0; | ||
|
||
} | ||
|
||
int main(){ | ||
|
||
string num; cin >> num; | ||
cout << (checkLuckyNumber(num) ? "YES" : "NO"); | ||
|
||
} |
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 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int checkSquareStr(string str) { | ||
|
||
string str1 = "", str2 = ""; | ||
int size = str.length(); | ||
for(int i = 0; i < size; ++i) { | ||
if(i < size/2) | ||
str1.push_back(str[i]); | ||
else | ||
str2.push_back(str[i]); | ||
} | ||
|
||
return str1 == str2; | ||
|
||
} | ||
|
||
int main() { | ||
|
||
int n; cin >> n; | ||
while(n--) { | ||
string str; cin >> str; | ||
cout << (checkSquareStr(str) ? "Yes" : "No") << endl; | ||
} | ||
|
||
} |
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,53 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
|
||
int n, k; | ||
cin >> n >> k; | ||
vector<int> fact; | ||
|
||
if(k == 1) { | ||
cout << n << endl; | ||
return 0; | ||
} | ||
|
||
int count = 0; | ||
for (int i = 2; i * i <= n; ++i) | ||
{ | ||
if (n % i == 0 and count < k) | ||
{ | ||
while (n % i == 0 and count < k) | ||
{ | ||
n /= i; | ||
fact.push_back(i); | ||
count++; | ||
|
||
if (count == k - 1 and n != 1) | ||
{ | ||
fact.push_back(n); | ||
n /= n; | ||
count++; | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (n != 1) | ||
{ | ||
fact.push_back(n); | ||
count++; | ||
} | ||
|
||
if (count == k) | ||
{ | ||
for (auto x : fact) | ||
cout << x << " "; | ||
cout << endl; | ||
} | ||
else | ||
{ | ||
cout << -1 << endl; | ||
} | ||
} |