Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#1 problem
- #include <iostream>
- using namespace std;
- int main(){
- string s, t;
- cin >> s;
- for(int i = s.size() / 2 - 1; i >= 0; --i){
- t += s[i];
- }
- if(s.size() % 2 == 1){
- t += s[s.size() / 2];
- for(int i = s.size() - 1; i >= s.size() / 2 + 1; --i){
- t += s[i];
- }
- }else{
- for(int i = s.size() - 1; i >= s.size() / 2; --i){
- t += s[i];
- }
- }
- cout << t << endl;
- return 0;
- }
- //#2 problem
- #include <iostream>
- #include <map>
- #include <vector>
- using namespace std;
- int singleNumber(vector<int>& nums) {
- map<int, int> m;
- map<int, int>::iterator it;
- for(int i = 0; i < nums.size(); ++i){
- m[nums[i]]++;
- }
- for(it = m.begin(); it != m.end(); ++it){
- if((*it).s != 2){
- return (*it).f;
- }
- }
- }
- //#3 problem
- #include <iostream>
- using namespace std;
- int a[30], b[30];
- int main(){
- string s, t;
- cin >> s >> t;
- for(int i = 0; i < s.size(); ++i){
- int cur = s[i] - 'a';
- a[cur]++;
- }
- for(int i = 0; i < t.size(); ++i){
- int cur = t[i] - 'a';
- b[cur]++;
- }
- for(int i = 0; i < t.size(); ++i){
- int cur = t[i] - 'a';
- if(b[cur] > a[cur]){
- cout << (char)(cur + 'a');
- b[cur]--;
- }
- }
- return 0;
- }
- //#4 problem
- #include <iostream>
- using namespace std;
- int a[5];
- int main(){
- string s;
- cin >> s;
- for(int i = 0; i < s.size(); i += 2){
- a[s[i] - '0']++;
- }
- int cnt = a[1] + a[2] + a[3];
- int col = 0;
- for(int i = 1; i <= 3; ++i){
- if(a[i] != 0){
- for(int j = 0; j < a[i]; ++j){
- col++;
- cout << i;
- if(col != cnt)
- cout << "+";
- }
- }
- }
- return 0;
- }
- //#5 problem
- #include <iostream>
- using namespace std;
- const int inf = (int)1e9;
- int n, a[1100];
- int main(){
- cin >> n;
- for(int i = 0; i < n; ++i){
- int x;
- cin >> x;
- a[x]++;
- }
- int cnt = 0;
- for(int i = 0; i < 1100; ++i){
- if(a[i] > 0)
- cnt++;
- }
- int mx = -inf;
- for(int i = 0; i < 1100; ++i){
- mx = max(mx, a[i]);
- }
- cout << mx << " " << cnt << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement