Compare commits

...

2 commits

Author SHA1 Message Date
2be90bb54d fix gitignore + remove swp file 2025-05-07 21:51:06 +03:00
0b1d62ffb5 add c++ solution of #3060 2025-05-07 21:50:31 +03:00
2 changed files with 36 additions and 0 deletions

2
.gitignore vendored
View file

@ -250,3 +250,5 @@ Module.symvers
Mkfile.old
dkms.conf
a.out
*.swp

34
3060/solutie.cpp Normal file
View file

@ -0,0 +1,34 @@
#include <iostream>
using namespace std;
int main() {
int k=0, p=0, n=0, i=0;
cin >> k;
cin >> p;
for (i = 9999; i >= 0; i--) {
bool prime = true;
for (int j = 2; j < i; j++) {
if (i % j == 0) {
prime = false;
}
}
bool containsForbiddenNumber = false;
if (prime) {
int c = i;
while (c > 0) {
if (c % 10 == k || c % 10 == p) {
containsForbiddenNumber = true;
break;
}
c = c / 10;
}
}
if (prime && !containsForbiddenNumber) {
n = i;
break;
}
}
cout << n;
return 0;
}