#include <iostream>
#include<vector>
using namespace std;
int square(int x){
for (int i = 1; i <= 45; ++i){
if (i * i <= x){
continue;
}
return (i - 1) * (i - 1);
}
}
int main()
{
int x, y, xwas, ywas, xywas;
cin >> x >> y;
xwas = square(x);
ywas = square(y);
xywas = square(x + y);
if (xwas + ywas < xywas){
cout << "Petya gives paint to Vasya";
}
else if (xwas + ywas == xywas){
cout << "Equal";
}
else {
cout << "Petya leaves paint to himself";
}
return 0;
}#include <iostream>
#include<vector>
using namespace std;
int square(int x){
for (int i = 1; i <= 45; ++i){
if (i * i <= x){
continue;
}
return (i - 1) * (i - 1);
}
}
int main()
{
int x, y, xwas, ywas, xywas;
cin >> x >> y;
xwas = square(x);
ywas = square(y);
xywas = square(x + y);
if (xwas + ywas < xywas){
cout << "Petya gives paint to Vasya";
}
else if (xwas + ywas == xywas){
cout << "Equal";
}
else {
cout << "Petya leaves paint to himself";
}
return 0;
}
Объяснение:
#include lt;iostreamgt;
#include lt;cstringgt;
#include lt;vectorgt;
#include lt;algorithmgt;
struct StudentData
{
std::string name;
std::string surname;
int math;
int phys;
int comp_science;
};
bool
comp(const StudentData amp;a, const StudentData amp;b)
{
int tmp1 = a.math + a.phys + a.comp_science;
int tmp2 = b.math + b.phys + b.comp_science;
return tmp1 gt; tmp2 true : false;
}
int
main(void)
{
int n;
std::cin gt;gt; n;
std::vectorlt; StudentData gt; data(n);
for (int i = 0; i lt; n; i++) {
std::cin gt;gt; data[i].name gt;gt; data[i].surname;
std::cin gt;gt; data[i].math gt;gt; data[i].phys gt;gt; data[i].comp_science;
}
std::sort(data.begin(), data.end(), comp);
for (int i = 0; i lt; n; i++) {
std::cout lt;lt; data[i].name lt;lt; " " lt;lt; data[i].surname lt;lt; std::endl;
}
return 0;
}
Объяснение: