Français
Ouvrir dans Telegram

Fil de discussionnimaga bu memory limit olyapti?

2 messages · –
#
Fichier
image_2024-07-15_22-59-00.png · 8 Ko · cliquez pour afficher
nimaga bu memory limit olyapti? #include <iostream> #include <vector> #include <string> #include <bitset> #include <algorithm> std::string binstr(int num) { std::string bin = std::bitset<32>(num).to_string(); const auto pos = bin.find_first_not_of('0'); if (pos != std::string::npos) { return bin.substr(pos); } return "0"; } int foo(int a, int b) { std::vector<std::string> x; std::string y = ""; int d = 0; for (int i = a; i <= b; ++i) { std::string s = binstr(i); x.push_back(s); y += s; int ones = std::count(y.begin(), y.end(), '1'); int zeros = y.size() - ones; if (y.size() % 2 == 0 && ones == zeros) { d += 1; } else { y = ""; } } return d; } int main() { int a, b; std::cin >> a >> b; std::cout << foo(a, b) << std::endl; return 0; } https://robocontest.uz/tasks/1211
CC++ vs PythonC++ vs Python@cpp_vs_python · groupe · Technologie
114membres39 409messages dans l'index
Fil de la communauté Ouvrir dans Telegram

Un fil public ouvert issu de l'index de recherche ChatCrawler — « le Google du Telegram public » ; actualisé à mesure que la communauté est explorée. Les heures sont en UTC.

Contenu public uniquement, API officielle de Telegram. À propos · FAQ · Limites de l'index · Retirer une page · Catalogue · Recherche · Comment nous comptons