前言:
个人整理必有重复毕竟题目一样也有非最优答案,勿喷。
信息学奥赛一本通(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;
}
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;
}
1058:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double a,b,c,x1,x2;
cin>>a>>b>>c;
x1=(-b+sqrt(b*b-4*a*c))/(2*a);
x2=(-b-sqrt(b*b-4*a*c))/(2*a);
if(!(isnan(x1)||isnan(x2)))
{
cout.precision(5);
cout<<fixed;
if(x1==x2)
{
cout<<"x1=x2="<<x1;
}
else if(x1<x2)
{
cout<<"x1="<<x1<<";x2="<<x2;
}
else
{
cout<<"x1="<<x2<<";x2="<<x1;
}
}
else
{
cout<<"No answer!";
}
return 0;
}
1059:
#include <iostream>
using namespace std;
int main()
{
float n,p=0;
cin>>n;
for(int i=0;i<n;i++)
{
int k;
cin>>k;
p+=k;
}
printf("%.2f",p/n);
return 0;
}
106*:
1060:
#include <iostream>
using namespace std;
int main()
{
float n,p=0;
cin>>n;
for(int i=0;i<n;i++)
{
float k;
cin>>k;
p+=k;
}
printf("%.4f",p/n);
return 0;
}
1061:
#include <iostream>
using namespace std;
int main()
{
int n,p=0;
cin>>n;
for(int i=0;i<n;i++)
{
int k;
cin>>k;
p+=k;
}
cout.precision(5);
cout<<p<<" "<<fixed<<double(p)/double(n);
return 0;
}
1062:
#include <iostream>
using namespace std;
int main()
{
short int n,p=0;
cin>>n;
for(short int i=0;i<n;i++)
{
short int k;
cin>>k;
p=(k>p)?k:p;
}
cout<<p;
return 0;
}
1063:
#include <iostream>
using namespace std;
int main()
{
short int n,b=0,s=1000;
cin>>n;
for(short int i=0;i<n;i++)
{
short int k;
cin>>k;
if(k>b)b=k;
if(k<s)s=k;
}
cout<<b-s;
return 0;
}
1064:
#include <iostream>
using namespace std;
int main()
{
unsigned short int n,j=0,y=0,t=0;
cin>>n;
for(short int i=0;i<n;i++)
{
unsigned short int dj,dy,dt;
cin>>dj>>dy>>dt;
j+=dj;
y+=dy;
t+=dt;
}
cout<<j<<" "<<y<<" "<<t<<" "<<j+y+t;
return 0;
}
1065:
#include<iostream>
using namespace std;
int main() {
int n, m,l=0;
cin >> m >> n;
for (int i = m; i <= n; i++) {
if (i % 2 == 1)l += i;
}
cout << l;
return 0;
}
1066:
#include <iostream>
using namespace std;
int main()
{
int m,n,k=0;
cin>>m>>n;
for(int i=m;i<=n;i++)
{
if(i%17==0)
{
k+=i;
i+=16;
}
}
cout<<k;
return 0;
}
1067:
#include<iostream>
using namespace std;
int main() {
int a=0, b=0, c=0, d;
while (cin >> d) {
if (d == 1)a++;
if (d == 5)b++;
if (d == 10)c++;
}
cout << a << "\n" << b << "\n" << c;
return 0;
}
1068:
#include <iostream>
using namespace std;
int main(){
int n,m,c;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
int o;
cin>>o;
if(o==m)c++;
}
cout<<c;
return 0;
}
1069:
#include <iostream>
#include<math.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
printf("%.0f",pow(a,b));
return 0;
}