Skip to content

Commit

Permalink
kickstart2022
Browse files Browse the repository at this point in the history
  • Loading branch information
kunheekimkr committed Mar 24, 2022
1 parent 2c7cefe commit cc37e7c
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 0 deletions.
Binary file added kickstart2022/a
Binary file not shown.
29 changes: 29 additions & 0 deletions kickstart2022/a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include<iostream>
#include<string>
using namespace std;
int main(){
int t;
cin >> t;
for(int tc=1; tc<=t; tc++){
string i, p;
cin >> i >> p;
int ans =0;
int size_i = i.size();
int size_p = p.size();
int j=0;
int k=0;
cout << "Case #" << tc <<": ";
for(j; j<size_i; j++){
while(k <size_p && i[j] != p[k])
k++;
if( k == size_p)
break;
k++;
}
if( j == size_i)
cout << p.size() - i.size() << '\n';
else
cout << "IMPOSSIBLE\n";

}
}
Binary file added kickstart2022/b
Binary file not shown.
43 changes: 43 additions & 0 deletions kickstart2022/b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
for(int tc=1; tc<=t; tc++){
string n;
cin >> n;
int size =n.size();
int sum = 0;
for(int i=0; i< size; i++)
sum += (n[i] - '0');
int newdigit = 9 - sum % 9;
if(newdigit ==9)
newdigit = 0;

cout << "Case #" << tc << ": ";
if(newdigit ==0){
cout << n[0];
cout << newdigit;
for(int i = 1; i<size; i++)
cout << n[i];
}
else{
int i = 0;
for(i; i<size; i++){
if( n[i] <= newdigit + '0')
cout << n[i];
else
break;
}
cout << newdigit ;
for(i; i<size; i++){
cout << n[i];
}
}
cout << '\n';
}
}
26 changes: 26 additions & 0 deletions kickstart2022/c.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include<iostream>
#include<string>
using namespace std;


int main(){
int t;
cin >> t;
for(int tc=1; tc<=t; tc++){
int n;
string s;
cin >> n >> s;
bool ans = false;
for(int i=0; i < s.size(); i++){
if(check(i)){
ans = true;
break;
}
}
cout << "Case #" << tc << ": ";
if(ans)
cout << "POSSIBLE\n";
else
cout << "IMPOSSIBLE\n";
}
}
Binary file added kickstart2022/d
Binary file not shown.
24 changes: 24 additions & 0 deletions kickstart2022/d.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<iostream>
using namespace std;
int main(){
int t;
cin >> t;
for(int tc=1; tc<=t; tc++){
long long a, b;
cin >> a >> b;
long long ans=0;
for(long long i=a; i<=b; i++){
long num = i;
long sum =0;
long product = 1;
while(num){
sum += num%10;
product *= num%10;
num /= 10;
}
if( product % sum ==0)
ans++;
}
cout << "Case #" << tc << ": " << ans << '\n';
}
}

0 comments on commit cc37e7c

Please sign in to comment.