信息学奥赛一本通(C++)在线测评 部分答案

前言:

个人整理必有重复毕竟题目一样也有非最优答案,勿喷。

信息学奥赛一本通(C++)在线测评 链接

在此声明: 如有侵权非有意为之。

题目答案

100*:

        1000:

#include<iostream>
using namespace std;

int main(){
    int a,s;
    cin>>a>>s;
    cout<<a+s;
    return 0;
}

        1001:

#include<iostream>
using namespace std;

int main(){
    cout<<"Hello,World!";
    return 0;
}

        1002:

#include<iostream>
using namespace std;

int main(){
    int q,a,z;
    cin>>q>>a>>z;
    cout<<a;
    return 0;
}

        1003:

#include<iostream>
using namespace std;

int main() {
	int a, s, d;
	cin >> a >> s >> d;
	printf("%8d %8d %8d", a, s, d);
	return 0;
}

        1004:

#include<iostream>
using namespace std;

int main() {
	char a;
	cin >> a;
	cout << " " << " " << a << " " << " " << endl;
	cout << " " << a << a << a << " " << endl;
	cout << a << a << a << a << a << endl;
	return 0;
}

         1005:

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int x,y,a,b;
    double z;
    cin>>x>>a>>y>>b;
    z=(y*b-x*a)/(b-a);
    printf("%.2f",z);
    return 0;
}

        1006: 

#include<iostream>
using namespace std;

int main(){
    int a,s;
    cin>>a>>s;
    cout<<a+s;
    return 0;
}

        1007:

#include<iostream>
using namespace std;

int main(){
    int a,q,z,w;
    cin>>a>>q>>z;
    w=a+q;
    cout<<w*z;
    return 0;
}

        1008:

#include<iostream>
using namespace std;

int main(){
    int a,aa,aaa;
    cin>>a>>aa>>aaa;
    cout<<(a+aa)/aaa;
    return 0;
}

        1009:

#include<iostream>
using namespace std;

int main(){
    int a,s,d;
    cin>>a>>s;
    d=a/s;
    cout<<d<<" "<<a%s;
    return 0;
}

        101*:

        1010:

#include<iostream>
using namespace std;

int main(){
	double d,a,b;
	cin>>a>>b;
	d=a/b;
	printf("%.9f",d);
	return 0;
}

        1011:

#include<iostream>
using namespace std;

int main(){
	double d,a,b;
	cin>>a>>b;
	d=b/a*100;
	printf("%.3f",d);
	cout<<"%";
	return 0;
}

        1012:

#include<iostream>
#include<math.h>
using namespace std;

int main(){
	double x,a,b,c,d,p;
	cin>>x>>a>>b>>c>>d;
	p=(a*pow(x,3)+b*pow(x,2)+c*x+d);
	printf("%.7f",p);
	return 0;
}

        1013:

#include<iostream>
#include<math.h>
using namespace std;

int main(){
	double F,C;
	cin>>F;
	C=5*(F-32)/9;
	printf("%.5f",C);
	return 0;
}

        1014:

#include<iostream>
#include<math.h>
using namespace std;

int main(){
	double F,C;
	cin>>F;
	printf("%.4f",F*2);
	cout<<" ";
	printf("%.4f",F*2*3.14159);
	cout<<" ";
	printf("%.4f",F*F*3.14159);
	return 0;
}

        1015:

#include<iostream>
using namespace std;

int main(){
	double r1,r2;
	cin>>r1>>r2;
	printf("%.2f",1/(1/r1+1/r2));
	return 0;
}

        1016:

#include<iostream>
using namespace std;

int main(){
	cout<<sizeof(int)<<" "<<sizeof(short);
	return 0;
}

         1017:

#include<iostream>
using namespace std;

int main(){
	cout<<sizeof(float)<<" "<<sizeof(double);
	return 0;
}

        1018:

#include<iostream>
using namespace std;

int main(){
	cout<<sizeof(bool)<<" "<<sizeof(char);
	return 0;
}

        1019:

#include<iostream>
using namespace std;

int main(){
    double a;
    int q;
    cin>>a;
    q=a;
    cout<<q;
    return 0;
}

         102*:

        1020:

#include<iostream>
using namespace std;

int main(){
    int a;
    char s;
    cin>>s;
    a=s;
    cout<<a;
    return 0;
}

        1021:

#include<iostream>
using namespace std;

int main(){
    char a;
    int s;
    cin>>s;
    a=s;
    cout<<a;
    return 0;
}

        1022:

#include<iostream>
using namespace std;

int main(){
    bool a;
    int s;
    cin>>s;
    a=s;
    s=a;
    cout<<s;
    return 0;
}

        1023:

#include<iostream>
using namespace std;

int main(){
	cout<<sizeof("Hello,World");
	return 0;
}

        1024:

#include<iostream>
using namespace std;

int main(){
	float a;
	cin>>a;
	printf("%.3f",a);
	return 0;
}

        1025:

#include<iostream>
using namespace std;

int main(){
	double a;
	cin>>a;
	printf("%.12f",a);
	return 0;
}

        1026:

#include<iostream>
using namespace std;

int main(){
	char a;
	int b;
	float c;
	double d;
	cin>>a>>b>>c>>d;
	printf("%c %d %f %f",a,b,c,d);
	return 0;
}

        1027:

#include<iostream>
using namespace std;

int main(){
	double a;
	cin>>a;
	printf("%f\n%.5F\n%e\n%g",a,a,a,a);
	return 0;
}

        1028:

#include<iostream>
using namespace std;

int main(){
	char a;
	cin>>a;
	cout
        <<"  "<<a<<"\n"
        <<" "<<a<<a<<a<<"\n"
        <<a<<a<<a<<a<<a<<"\n"
        <<" "<<a<<a<<a<<"\n"
        <<"  "<<a;
	return 0;
}

        1029:

#include<iostream>
using namespace std;

int main(){
	int k;
	double a,b,r;
	cin>>a>>b;
	k=a/b;
	r=a-k*b;
	cout<<r;
	return 0;
}

        103*:

        1030:

#include<iostream>
#include<math.h>
using namespace std;

int main(){	
	double r,V,s;
	cin>>r;
	s=double(4)/double(3);
	V=s*3.14*pow(r,3);
	printf("%.2f",V);
	return 0;
}

        1031:

#include<iostream>
using namespace std;

int main() {
	int a;
	cin >> a;
	for (int i = 0; i < 3; i++)
	{
		cout << a%10;
		a /= 10;
	}
	return 0;
}

        1032:

#include<iostream>
#include<math.h>
using namespace std;

int main(){	
	int h,r;
	double t;
	cin>>h>>r;
	t=20000/(pow(r,2)*3.14*h);
	printf("%.0f",t+0.5);
	return 0;
}

        1033:

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
double x1,x2,x3,y1,y2,y3,p,s,a,b,c;
cout.precision(2);
cin>>x1>>y1>>x2>>y2>>x3>>y3;
a=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
b=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2)); 
c=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
cout<<fixed<<s; 
return 0;
}

         1034:

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
double x1,x2,x3,y1,y2,y3,p,s,a,b,c;
cout.precision(2);
cin>>x1>>y1>>x2>>y2>>x3>>y3;
a=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
b=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2)); 
c=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
cout<<fixed<<s; 
return 0;
}

        1035:

#include<iostream>
using namespace std;
int main (){
	int a1,a2,n;
	cin >>a1>>a2>>n;
	int q=a2-a1;
	cout <<a1+(n-1)*q;
	return 0;
}

        1036:

#include<iostream>
using namespace std;

int main(){
    long long int A,B;
    cin>>A>>B;
    cout<<A*B;
    return 0;
}

         1037:

#include<cstdio>
#include<cmath>
int main(){
	int n;
	scanf("%d",&n);
	printf("%d",(int)pow(2,n));
	return 0;
}

         1038:

#include<iostream>
using namespace std;

int main() {
	int n, x, y;
	cin >> n >> x >> y;
	if (y % x != 0) {
		n--;
	}
	if (y / x >= n) {
		cout << 0;
		return 0;
	}
	cout << n - y / x;
	return 0;
}

        1039:

#include<iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n >= 0)
	{
		if (n > 0) {
			cout << "positive";
			return 0;
		}
		cout << "zero";
		return 0;
	}
	cout << "negative";
	return 0;
}

        104*:

        1040:

#include<iostream>
#include<cmath>
using namespace std;

int main() {
	double n;
	cin >> n;
	cout << fabs(n);
	return 0;
}

        1041:

#include<iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n % 2 != 0) {
		cout << "odd";
	}
	else {
		cout << "even";
	}
	return 0;
}

        1042:

#include<iostream>
using namespace std;

int main() {
	char n;
	cin >> n;
	if ((char)n % 2 != 0) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

        1043:

#include<iostream>
using namespace std;

int main() {
	long int x,y;
	cin >> x>>y;
	if (x>=y)
	{
		if (x==y)
		{
			cout << "="; 
			return 0;
		}
		cout << ">";
		return 0;
	}
	cout << "<";
	return 0;
}

        1044:

#include<iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n>9&&n<100)
	{
		cout << 1;
	}
	else {
		cout << 0;
	}
	return 0;
}

        1045:

#include<iostream>
using namespace std;

int main() {
	int x, y;
	cin >> x >> y;
	if (x >= 10 || y >= 20) {
		cout << 1;
	}
	else {
		cout << 0;
	}
	return 0;
}

        1046:

#include<iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n%3==0&&n%5==0)
	{
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

        1047:

#include<iostream>
using namespace std;

int main() {
	int a,w=0;
	cin >> a;
	if (a % 3 == 0) {
		cout << 3 << " ";
		w = 1;
	}
	if (a % 5 == 0) {
		cout << 5 << " ";
		w = 1;
	}
	if (a%7==0) {
		cout << 7 << " ";
		w = 1;
	}
	if (w == 0) {
		cout << "n";
	}
	return 0;
}

        1048:

#include<iostream>
using namespace std;

int main() {
	int a, s, d; 
	d = 0;
	cin >> a >> s;
	if (a<60)
	{
		d++;
	}
	if (s<60)
	{
		d++;
	}
	if (d==1)
	{
		cout << "1";
	}
	else
	{
		cout << "0";
	}
	return 0;
}

        1049:

#include<iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	switch (n)
	{
	case 1:cout << "NO"; break;
	case 3:cout << "NO"; break;
	case 5:cout << "NO"; break;
	default:cout << "YES"; break;
	}
	return 0;
}

        105*:

        1050:

#include<iostream>
using namespace std;

int main() {
	double b, w={0}, m;
	b = 50;
	cin >> m;
	b += m / 3;
	w += m / 1.2;
	if (b==w)
	{
		cout << "All";
	}
	else {
		if (b<w)
		{
			cout << "Bike";
		}
		else {
			cout << "Walk";
		}
	}
	return 0;
}

        1051:

#include<iostream>
using namespace std;

int main() {
	double x,y;
	cin >> x;
	if (0<=x&&x<5)
	{
		y = -x + 2.5;
	}
	if (5<=x&&x<10)
	{
		y=2 - 1.5 * (x - 3) * (x - 3);
	}
	if (10 <= x && x < 20) {
		y = x / 2 - 1.5;
	}
	printf("%.3f", y);
	return 0;
}

        1052:

#include<iostream>
using namespace std;

int main() {
	int x,m=8;
	char y;
	cin >> x >> y;
	x -= 1000; 
	if (y=='y')m += 5;
	while (x > 0) {
		x -= 500;
		m += 4; 
	}
	cout << m;
	return 0;
}

        1053:

#include<iostream>
#include<algorithm>
using namespace std;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[2];
	return 0;
}

        1054:

#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;
}

        1055:

#include<iostream>
using namespace std;

int main() {
	int a;
	cin >> a;
	if (a%4==0&&a%100!=0||a%400==0)
	{
		cout << "Y";
	}
	else
	{
		cout << "N";
	}
	return 0;
}

        1056:

#include<iostream>
using namespace std;

int main() {
	int x, y;
	cin >> x >> y;
	if (x <= 1 && y <= 1 && x >= -1 && y >= -1)cout << "yes";
	else cout << "no";
	return 0;
}

        1057:

#include<iostream>
using namespace std;

int main() {
	int a, b;
	char c;
	cin >> a >> b >> c;
	if (c=='+')
	{
		cout << a + b;
	}
	else if (c=='-')
	{
		cout << a - b;
	}
	else if (c == '*')
	{
		cout << a * b;
	}
	else if (c == '/') {
		if (b!=0)
		{
			cout << a / b;
		}
		else
		{
			cout << "Divided by zero!";
		}
	}
	else
	{
		cout << "Invalid operator!";
	}
	return 0;
}

        

未完待续

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值