init commit

This commit is contained in:
2025-04-13 21:48:15 +03:00
commit 23255e9121
192 changed files with 12200 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
#include <iostream>
#include <vector>
#include <algorithm>
bool comp(unsigned int a, unsigned int b) {
int res1 = 0;
while (a != 0) {
res1 += a & 1;
a = a >> 1;
}
int res2 = 0;
while (b != 0) {
res2 += b & 1;
b = b >> 1;
}
return res1 < res2;
}
int main() {
std::vector<unsigned int> v;
unsigned int tmp;
while (std::cin >> tmp) {
v.push_back(tmp);
}
std::stable_sort(v.begin(), v.end(), comp);
for (auto x : v) {
std::cout << x << std::endl;
}
return 0;
}
+28
View File
@@ -0,0 +1,28 @@
#include <map>
#include <vector>
#include <iostream>
int main() {
std::map<std::string, std::vector<int>> mp;
std::string name;
int grade;
while (std::cin >> name >> grade) {
mp[name].push_back(grade);
}
for (auto x : mp) {
std::cout << x.first << " ";
double tmp = 0;
int n = 0;
for (auto i : x.second) {
tmp += i;
++n;
}
std::cout << tmp / n << std::endl;
}
return 0;
}
View File
+26
View File
@@ -0,0 +1,26 @@
#include <map>
#include <iostream>
int main() {
long long mod = 4294967161;
std::map<std::pair<long long, long long>, long long> mp;
long long r, c, v;
while (std::cin >> r >> c >> v) {
if (!r && !c && v == mod) break;
mp[std::make_pair(r, c)] = v;
}
while (std::cin >> r >> c >> v) {
mp[std::make_pair(r, c)] += v;
mp[std::make_pair(r, c)] %= mod;
}
for (auto x : mp) {
if (x.second) std::cout << x.first.first << " " << x.first.second << " " << x.second << std::endl;
}
return 0;
}
+26
View File
@@ -0,0 +1,26 @@
#include <map>
#include <iostream>
int main() {
long long mod = 4294967161;
std::map<std::pair<long long, long long>, long long> mp;
long long r, c, v;
while (std::cin >> r >> c >> v) {
if (!r && !c && v == mod) break;
mp[std::make_pair(r, c)] = v;
}
while (std::cin >> r >> c >> v) {
// mp[std::make_pair(r, c)] *= v;
mp[std::make_pair(r, c)] %= mod;
}
for (auto x : mp) {
if (x.second) std::cout << x.first.first << " " << x.first.second << " " << x.second << std::endl;
}
return 0;
}