Skip to content

Commit

Permalink
adding some problems from cses and codeforces
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanashii76 committed Sep 16, 2024
1 parent 4ef182a commit 15a78e7
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Codeforces/codeforces_problemset/110A.cpp
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");

}
27 changes: 27 additions & 0 deletions Codeforces/codeforces_problemset/1619A.cpp
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;
}

}
53 changes: 53 additions & 0 deletions Codeforces/codeforces_problemset/797A.cpp
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;
}
}

0 comments on commit 15a78e7

Please sign in to comment.