bạn nào giúp mình làm bài này được ko! làm bằng pascal ấy
Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
#include <iostream>
#include <regex>
#include <stack>
#include <vector>
using namespace std;
void delNum(string n) {
int k = n.length() - 5;
stack<int> digits;
for (long i = 0; i < n.length(); i++) {
int tmp = n[i] - 0;
if (digits.empty()) digits.push(tmp);
else {
while (!digits.empty() && tmp > digits.top() && k > 0) {
digits.pop();
k--;
}
digits.push(tmp);
}
}
while (k > 0 && !digits.empty()) {
digits.pop();
k--;
}
vector<char> chars;
while (!digits.empty()) {
int tmp = digits.top();
digits.pop();
chars.push_back(tmp);
}
for (long i = chars.size() - 1; i >= 0; i--) cout << chars[i];
}
int main() {
string s;
cin >> s;
string n = regex_replace(s, regex(R"([\D])"), "");
delNum(n);
return 0;
}
...
Vẫn còn nữa nhé. Bạn truy cập trang web này: https://hoc24.vn/danh-hieu
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;
int countDivisors(int num) {
int count = 0;
for (int i = 1; i <= num; i++) {
if (num % i == 0) {
count++;
}
}
return count;
}
int main() {
int N;
cin >> N;
unordered_map<int, int> classMap;
for (int i = 0; i < N; i++) {
int num;
cin >> num;
int divisors = countDivisors(num);
classMap[divisors]++;
}
cout << classMap.size() << endl;
for (auto it = classMap.begin(); it != classMap.end(); it++) {
cout << it->first << " " << it->second << endl;
}
return 0;
}
def count_minimum_stones(n, colors):
count = 0
for i in range(n-1):
if colors[i] == colors[i+1]:
count += 1
return count
n = int(input())
colors = input().split()
result = count_minimum_stones(n, colors)
print(result)