东方博宜oj答案1000-1050(免费可复制)

由于是第一次发东方博宜答案,所以有一点不太熟练,不喜勿喷

后续还会继续出关于东方博宜oj的答案,想要了解更多也欢迎关注谢谢

1000

#include <iostream>
using namespace std;
int main()
{
    int a;
    int b;
    cin >> a >> b;
    cout << a+b;
    return 0;
}

 1001

#include <iostream>
using namespace std;
int main()
{
	int a;
	cin >> a;
	int sum = 0;
	for (int i = 1; i <= a; i++)
	{
		sum += i;
	}
	cout << sum;
	return 0;
}

1002

#include <iostream>
using namespace std;
int main()
{
	int a;
	cin >> a;
	int sum = 0;
	for (int i = 1; i <= a; i++)
	{
		sum += i;
	}
	cout << sum;
	return 0;
}

1003

#include <iostream>
using namespace std;
int main()
{
	int a;
	cin >> a;
	int sum = 0;
	for (int i = 1; i <= a; )
	{
		sum += i;
		i += 2;
	}
	cout << sum;
	return 0;
}

1004

#include <iostream>
using namespace std;
int main()
{
	int a;
	cin >> a;
	int sum = 1;
	for (int i = 1; i <= a; i++)
	{
		sum *= i;
	}
	cout << sum;
	return 0;
}

1005

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
	const double PI = 3.1415926;
	int a;
	cin >> a;
	cout << fixed << setprecision(2) << PI * a * a << endl;
	cout << fixed << setprecision(2) << 2 * PI * a;
	return 0;
}

1006

#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= 6 * n - 3; j++)
		{
			if ((j >n-i && j < n+i) || (j > 3*n-i-1 && j < 3*n+i-1) || (j > 5 * n - i - 2 && j < 5 * n + i-2))
			{
				cout << "*";
			}
			else
			{
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

 1007

#include <iostream>
using namespace std;
int main()
{
	char a[80];
	int num = 0;
	int num2 = 0;
	for (int i = 0; i < 80; i++)
	{
		cin >> a[i];
		num++;
		if (a[i] == '.')
		{
			break;
		}
	}
	for (int i = 0; i < num; i++)
	{
		if ((int)a[i] >= 65 && (int)a[i] <= 90)
		{
			num2++;
		}
	}
	cout << num2;
	return 0;
}

1008

#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= 2 * n + 1; j++)
		{
			if (j>n-i&&j<n+i)
			{
				cout << i;
			}
			else
			{
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

1009

#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[101];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = n-1; i >= 0; i--)
	{
		cout << a[i] << " ";
	}
	return 0;
}

1010

#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int* p = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n - i - 1; j++)
		{
			if (p[j] > p[j + 1])
			{
				int temp = p[j + 1];
				p[j + 1] = p[j];
				p[j] = temp;
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		cout << p[i] << " ";
	}
	delete[]p;
	return 0;
}

1011

#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int i, j;
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n - i; j++)
		{
			cout << " ";
		}
		if (i == 1)
		{
			for (j = 1; j <= n; j++)
			{
				cout << "*";
			}
		}
		else
		{
			cout << "*";
			for (j = 1; j <= n + 2 * (i - 2); j++)
			{
				cout << " ";
			}
			cout << "*";
		}
		cout << endl;
	}
	for (i = n - 1; i >= 1; i--)
	{
		for (j = 1; j <= n - i; j++)
		{
			cout << " ";
		}
		if (i == 1)
		{
			for (j = 1; j <= n; j++)
			{
				cout << "*";
			}
		}
		else
		{
			cout << "*";
			for (j = 1; j <= n + 2 * (i - 2); j++)
			{
				cout << " ";
			}
			cout << "*";
		}
		cout << endl;
	}
	return 0;
}

1012

#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
	string str1;
	string str2;
	int num1 = 0;
	int word_number = 1;
	int nearest = 9999;
	int num2 = 0;//记录空格个数
	getline(cin, str1);
	getline(cin, str2);//这两个用来接收字符串
	str2 = " " + str2 ;//最重点!!在前面添加空格证明是单词,不然this中的is会被误判
	int a = str1.find(str2);//找到匹配的位置
	if (a >= 0)
	{
		for (int i = 0; i < str1.size(); i++)
		{
			if (str1[i] == ' ')
			{
				num2++;
				if (abs(i - a) < nearest)
				{
					nearest = abs(i - a);//空格离单词最近
					if (nearest == 0)
					{
						break;//0就是最近,不可能更小,直接break跳出循环
					}
				}
			}
		}
		cout << num2 + 1;//单词是空格个数的下一个,所以加一
	}
	else if (a < 0)
	{
		for (int i = 0; i < str1.size(); i++)
		{
			if ((str1[i] > 64 && str1[i] < 91) || (str1[i] > 96 && str1[i] < 123))//ASCII码中字母对应的值
			{
				num1++;
			}
		}
		cout << num1;
	}
	return 0;
}

1013

#include <iostream>
using namespace std;
int main()
{
	int t, x;
	for (int i = 100007; i < 999999; i += 10)
	{
		int t = i / 10;
		int x = 700000 + t;
		if (x % i == 0 && x / i == 4)
		{
			cout << i;
		}
	}
	return 0;
}

1014

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
	int n;
	cin >> n;
	double sum = 0;
	for (double i = 1; i <= n; i++)
	{
		sum += 1.0 / i;
	}
	cout << fixed << setprecision(3) << sum;
	return 0;
}

1015

#include <iostream>
using namespace std;
int main()
{
	cout << 20 << " " << 30;
	return 0;
}

1016

#include <iostream>
using namespace std;
int main()
{
	int X, A, B;
	cin >> X >> A >> B;
	int num = 0;
	for (int i = 1; i <X/A+1; i++)
	{
		for (int j = 1; j <=X/B+1; j++)
		{
			if (i * A + j * B == X)
			{
				num++;
			}
		}
	}
	cout << num;
	return 0;
}

1017

#include <iostream>
using namespace std;
int main()
{
	cout << 173;
	return 0;
}

1018

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int a[3];
	for (int i = 0; i < 3; i++)
	{
		cin >> a[i];
	}
	sort(a, a + 3);
	if (a[0] + a[1] > a[2] && pow(a[0], 2) + pow(a[1], 2) > pow(a[2], 2))
	{
		cout << "ruijiao";
	}
	else if (a[0] + a[1] > a[2] && pow(a[0], 2) + pow(a[1], 2) == pow(a[2], 2))
	{
		cout << "zhijiao";
	}
	else if (a[0] + a[1] > a[2] && pow(a[0], 2) + pow(a[1], 2) < pow(a[2], 2))
	{
		cout << "dunjiao";
	}
	else
	{
		cout << "no";
	}
	return 0;
}

1019

#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int sum = 0;
	int num = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i; j > 0; j--)
		{
			num *= j;
		}
		sum += num;
		num = 1;
	}
	cout << sum;
	return 0;
}

1020

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int sum = 0;
	int a, b, c;
	a = n / 100;
	b = n % 100 / 10;
	c = n % 100 % 10;
	sum = n + 100 * c + 10 * b + a;
	cout << sum;
	return 0;
}

   1021

#include <iostream>
using namespace std;
int main()
{
	for (int i = 1; i <= 500; i++)
	{
		if (i % 3 == 2 && i % 5 == 3 && i % 7 == 2)
		{
			cout << i << endl;
		}
	}
	return 0;
}

1022

#include <iostream>
using namespace std;
int main()
{
	for (int i = 1; i <= 20; i++)
	{
		for (int j = 30; j >= 0; j--)
		{
			if (7 * i + 4 * j == 100&&(100-i-j)%3==0)
			{
				cout << i << " " << j << " " << 100 - i - j << endl;
			}
		}
	}
	return 0;
}

1023

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int num = 0;
	if (n == 1)
	{
		cout << "F";
	}
	for (int i = 2; i < sqrt(n); i++)
	{
		if (n % i == 0&&n/i!=1&&n>=2)
		{
			num = 1;
			cout << "F";
			break;
		}
	}
	if (num == 0&&n>=2)
	{
		cout << "T";
	}
	return 0;
}

1024

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int num = 0;
	for (int i = 1; i <= 63; i++)
	{
		for (int j = 1; j <= 250; j++)
		{
			for (int k = 1; k <= 500; k++)
			{
				if (i + j + k > 30 && 8 * i + 2 * j + k == 10 * n)
				{
					num++;
				}
			}
		}
	}
	cout << num;
	return 0;
}

1025

#include <iostream>
using namespace std;
int main()
{
    cout << 461;
    return 0;
}

1026

#include <iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	cout << a / b << " " << a % b;
	return 0;
}

1027

#include <iostream>
using namespace std;
int main()
{
	int n, n1, g, s, b;
	cin >> n;
	g = n % 10;
	s = n % 100 / 10;
	b = n / 100;
	n1 = g + s + b;
	cout << n1;
	return 0;
}

1028

#include <bits/stdc++.h>
using namespace std;     
int main(){
	int n,n1,g,s,b;
	cin>>n;
	g=n%10;
	s=n%100/10;
	b=n/100;
	n1=g*100+s*10+b;
	cout<<n1;
	return 0;
}

1029

#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a = n / 1000;
	int b = n % 1000 / 100;
	int c = n % 1000 % 100 / 10;
	int d = n % 1000 % 100 % 10;
	cout << 1000 * d + 100 * c + 10 * b + a;
	return 0;
}

1030

#include <iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a % b == 0)
	{
		cout << a / b;
	}
	else if (a % b != 0)
	{
		cout << a / b + 1;
	}
	return 0;
}

1031

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
	double n;
	cin >> n;
	double f = (9 * n + 160) / 5.0;
	cout << fixed << setprecision(2) << f;
	return 0;
}

1032

#include <iostream>
using namespace std;
int main()
{
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if (a / 3 == 0)
	{
		a = 0;
	}
	else
	{
		a = (a - a % 3) / 3;
		b += a;
		e += a;
	}
	if (b / 3 == 0)
	{
		b = 0;
	}
	else
	{
		b = (b - b % 3) / 3;
		c += b;
		a += b;
	}
	if (c / 3 == 0)
	{
		c = 0;
	}
	else
	{
		c = (c - c % 3) / 3;
		d += c;
		b += c;
	}
	if (d / 3 == 0)
	{
		d = 0;
	}
	else
	{
		d = (d - d % 3) / 3;
		c += d;
		e += d;
	}
	if (e / 3 == 0)
	{
		e = 0;
	}
	else
	{
		e = (e - e % 3) / 3;
		a += e;
		d += e;
	}
	cout << a << " " << b << " " << c << " " << d << " " << e;
	return 0;
}

1033

#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	if (n % 2 == 0)
	{
		cout << "y e s";
	}
	else
	{
		cout << "n o";
	}
	return 0;
}



1034

#include <iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a > b)
	{
		cout << a;
	}
	else
	{
		cout << b;
	}
	return 0;
}

1035

#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	if (n >= 86)
	{
		cout << "VERY GOOD";
	}
	else if (n >= 60 && n < 86)
	{
		cout << "GOOD";
	}
	else
	{
		cout << "BAD";
	}
	return 0;
}

1036

#include <iostream>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b > c)
	{
		cout << "yes";
	}
	else
	{
		cout << "no";
	}
	return 0;
}

1037

#include <iostream>
using namespace std;
int main()
{
	double n;
	cin >> n;
	if (n < 1.3)
	{
		cout << "60";
	}
	else
	{
		cout << "120";
	}
	return 0;
}

1038

#include <iostream>
using namespace std;
int main()
{
	int x;
	cin >> x;
	if (x > 0)
	{
		cout << x + 1;
	}
	else if (x == 0)
	{
		cout << 0;
	}
	else
	{
		cout << x - 1;
	}
	return 0;
}

1039

#include <iostream>
using namespace std;
int main()
{
	int a, b, c;
	int d;
	cin >> a >> b >> c;
	d = (a > b) ? (a > c ? a : c) : (b > c ? b : c);
	cout << d;
	return 0;
}

1040

#include <iostream>
#include <algorithm>
using namespace std;
bool cmp(int a,int b)
{
	return a > b;
}
int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3, cmp);
	for (int i = 0; i < 3; i++)
	{
		cout << a[i] << " ";
	}
	return 0;
}

1041

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a[3];
	for (int i = 0; i < 3; i++)
	{
		cin >> a[i];
	}
	sort(a, a + 3);
	if (a[0] + 1 == a[1] && a[1] + 1 == a[2])
	{
		cout << "TRUE";
	}
	else
	{
		cout << "FALSE";
	}
	return 0;
}

1042

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a, b, c;
	a = n / 100;
	b = n % 100 / 10;
	c = n % 100 % 10;
	int d[3];
	d[0] = a;
	d[1] = b;
	d[2] = c;
	sort(d, d + 3);
	cout << d[2] * 100 + d[1] * 10 + d[0];
	return 0;
}

1043

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
	int n;
	cin >> n;
	double num = 0;
	if (n <= 10)
	{
		num = 2.5;
		cout << fixed << setprecision(2) << num;//保留小数,需要iomanip头文件
	}
	if (n > 10)
	{
		num = 1.5 * n - 12.5;
		cout << fixed << setprecision(2) << num;
	}
	return 0;
}

1044

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	if (n < 10)
	{
		cout << 'A';
	}
	else if (n >= 10 && n < 20)
	{
		cout << 'B';
	}
	else if (n >= 20 && n < 40)
	{
		cout << 'C';
	}
	else if (n >= 40 && n < 50)
	{
		cout << 'D';
	}
	else if (n >= 50 && n < 80)
	{
		cout << 'E';
	}
	return 0;
}

1045

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] + a[1] > a[2])
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}

1046

#include <iostream>
#include <algorithm>
using namespace std;
bool cmp(int a, int b)
{
	return a > b;
}
int main()
{
	int a[4];
	for (int i = 0; i < 4; i++)
	{
		cin >> a[i];
	}
	sort(a, a + 4);//升序排列
	if (a[0] + 2 == a[1] && a[1] + 2 == a[2] && a[2] + 2 == a[3])
	{
		cout << a[0] << "+2=" << a[1] << endl;
		cout << a[1] << "+2=" << a[2] << endl;
		cout << a[2] << "+2=" << a[3];
	}
	else
	{
		sort(a, a + 4, cmp);//降序排列
		for (int i = 0; i < 4; i++)
		{
			cout << a[i] << " ";
		}
	}
	return 0;
}

1047

#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
 
int main()
{
	double a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] + a[1] > a[2] && pow(a[0], 2) + pow(a[1], 2) == pow(a[2], 2))
	{
		cout << fixed << setprecision(1) << a[0] * a[1] / 2.0;
	}
	else
	{
		cout << "No";
	}
	return 0;
}

1048

#include <iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if ((a == 1 && b == 2) || (a == 2 && b == 3) || (a == 3 && b == 1))
	{
		cout << "win";
	}
	else if (a == b)
	{
		cout << "tie";
	}
	else
	{
		cout << "lose";
	}
	return 0;
}


1049

#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	if (n == 1)
	{
		cout << "one";
	}
	else if (n == 2)
	{
		cout << "two";
	}
	else if (n == 3)
	{
		cout << "three";
	}
	else if (n == 4)
	{
		cout << "four";
	}
	else if (n == 5)
	{
		cout << "five";
	}
	else if (n == 6)
	{
		cout << "six";
	}
	else if (n == 7)
	{
		cout << "seven";
	}
	else if (n == 8)
	{
		cout << "eight";
	}
	else if (n == 9)
	{
		cout << "nine";
	}
	else
	{
		cout << "out";
	}
	return 0;
}

1050

#include <iostream>
using namespace std;
int main()
{
	int a[4];
	int num = 0;
	int judge = 0;
	for (int i = 0; i < 4; i++)
	{
		cin >> a[i];
		if (a[i] >= 90)
		{
			num++;
		}
		if (a[i] < 60)
		{
			cout << "Poor LanYangYang";
			judge = 1;
			break;
		}
	}
	if (judge == 0 && num != 4)
	{
		cout << num;
	}
	if (judge == 0 && num == 4)
	{
		cout << 5;
	}
	return 0;
}

  • 19
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值