郑州轻工业的oj

郑州轻工业的oj

  • 1000
  • 1001
  • 1002
  • 1003
  • 1004
  • 1005
  • 1006
  • 1007
  • 1008
  • 1009
  • 1010
  • 1011
  • 1012
  • 1013
  • 1014
  • 1015
  • 1016
  • 1017
  • 1018
  • 1019
  • 1020
  • 1021
  • 1022
  • 1023
  • 1024
  • 1025
  • 1026
  • 1027
  • 1028
  • 1029
  • 1030
  • 1031
  • 1032
  • 1033
  • 1034
  • 1035
  • 1036
  • 1037
  • 1038
  • 1039
  • 1040
  • 1041
  • 1042
  • 1043
  • 1044
  • 1045
  • 1046
  • 1047
  • 1048
  • 1049
  • 1050
  • 1051
  • 1052
  • 1053
  • 1054
  • 1055
  • 1056
  • 1057
  • 1058
  • 1059
  • 1060
  • 1061
  • 1062
  • 1063
  • 1064
  • 1065
  • 1066
  • 1067
  • 1068
  • 1069
  • 1070
  • 1071
  • 1072
  • 1073
  • 1074
  • 1075
  • 1076
  • 1077
  • 1078
  • 1079
  • 1080
  • 1081
  • 1082
  • 1083
  • 1084
  • 1085
  • 1086
  • 1087
  • 1088
  • 1089
  • 1090
  • 1091
  • 1092
  • 1093
  • 1094
  • 1095
  • 1096
  • 1097
  • 1098
  • 1099
  • 1100
  • 1101
  • 1102
  • 1103
  • 1104
  • 1105
  • 1106
  • 1107
  • 1108
  • 1109
  • 1110
  • 1111
  • 1112
  • 1113
  • 1114

1000

# include
int main(void){
	printf("从今天开始入坑C语言");
	return 0;
} 
public class Main{
    public static void main(String[] args){
        System.out.println("从今天开始入坑C语言");
    }
}

1001

# include
int main(void){
	int a,b;
	scanf("%d%d",&a,&b);
//	scanf("%d",&b);
	int c=a+b;
	printf("%d",c);
} 
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scanner =new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.println(a+b);
    }
}

1002

# include
int main(void){
	int a,b;
	scanf("%d",&a);
	int c=2*a*a+a+8;
	printf("%d",c);
} 
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scanner =new Scanner(System.in);
        int a = scanner.nextInt();
        int b = 2*a*a+a+8;
        System.out.println(b);
    }
}

1003

# include
int main(void){
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d",a+b);
	printf(" ");
	printf("%d",a-b);
	printf(" ");
	printf("%d",a*b);
	printf(" ");
	printf("%d",a/b);
	printf(" ");
	printf("%d",a%b);
} 
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scanner =new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.print(a+b);
        System.out.print(" ");
        System.out.print(a-b);
        System.out.print(" ");
        System.out.print(a*b);
        System.out.print(" ");
        System.out.print(a/b);
        System.out.print(" ");
        System.out.print(a%b);
    }
}

1004

# include
int main(void){
    int a,b,c,d;
    scanf("%d",&a);
    b=a%10;
    a=a/10;
    c=a%10;
    a=a/10;
    d=a;
    printf("%d %d %d",b,c,d);
}
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scanner =new Scanner(System.in);
        int a = scanner.nextInt();
        int b= a%10;
        a=a/10;
        int c=a%10;
        a=a/10;
        int d=a%10;
        System.out.println(b+" "+c+" "+d);
    }
}

1005

# include
int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	printf("%-9d%-9d%-9d\n",a,a*a,a*a*a);
	printf("%-9d%-9d%-9d\n",b,b*b,b*b*b);
	printf("%-9d%-9d%-9d\n",c,c*c,c*c*c);
} 
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scanner =new Scanner(System.in);
        int a = scanner.nextInt();
        int a1 = scanner.nextInt();
        int a2 = scanner.nextInt();
        System.out.printf("%-9d%-9d%-9d\n",a,a*a,a*a*a);
        System.out.printf("%-9d%-9d%-9d\n",a1,a1*a1,a1*a1*a1);
        System.out.printf("%-9d%-9d%-9d",a2,a2*a2,a2*a2*a2);
    }
}

1006

# include
int main(void){
	int a,b,c,d;
	scanf("%d%d%d",&a,&b,&c);
	int sum =0;
	for(;a<=b;a=a+c){
		sum=sum+a;
	}
	printf("%d",sum);
} 
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scanner =new Scanner(System.in);
        int a = scanner.nextInt();
        int a1 = scanner.nextInt();
        int a2 = scanner.nextInt();
        int sum =0;
        for(;a<=a1;a=a+a2){
            sum =sum+a;
        }
        System.out.println(sum);
    }
}

1007

#include
#include
int main(void){
	int h,f;
	scanf("%d%d",&h,&f);
	bool flag =true;
	int j=0;
	int t=h-j;
	while(flag){
		if((2*j+4*t)==f){
			flag=false;
			printf("%d %d",j,t);
		}
		j=j+1;
		t=h-j;
	}
}
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scanner =new Scanner(System.in);
        int h = scanner.nextInt();
        int f = scanner.nextInt();
        int j=0,t=h-j;
        boolean flag=true;
        while(flag){
            if((2*j+4*t)==f){
                flag=false;
                System.out.println(j+" "+t);
            }
            j=j+1;
            t=h-j;
        }
    }
}

1008

#include
#include
int main(void){
	int m;
	scanf("%d",&m);
	double r = m*6.5573;
	printf("%0.2f",r);
}

import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scanner =new Scanner(System.in);
        int m = scanner.nextInt();
        double r = m*6.5573;
        System.out.printf("%.2f",r);
    }
}

1009

#include
#include
int main(void){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	double d=(double)(a+b+c)/3;
	printf("%.2f",d);
}

import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scanner =new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        double d=(double) (a+b+c)/3;
        System.out.printf("%.2f",d);
    }
}

1010

#include
#include
#define PI 3.14159
int main(void){
	double a;
	scanf("%lf",&a);
	double b=2*PI*a;
	double c=PI*a*a;
	printf("%.2f %.2f",b,c);
}

import java.util.Scanner;
public class Main{
    private static final double PI= 3.14159;
    public static void main(String[] args){
        Scanner scanner =new Scanner(System.in);
        double a = scanner.nextDouble();
        double b= 2*PI*a;
        double c=PI*a*a;
        System.out.printf("%.2f %.2f",b,c);
    }
}

1011

#include
#include
#define PI 3.14159
int main(void){
	double a,b;
	scanf("%lf %lf",&a,&b);
	double c=(PI*a*a*2+2*PI*a*b);
	printf("%.2f",c);
}

import java.util.Scanner;
public class Main{
    private static final double PI= 3.14159;
    public static void main(String[] args){
        Scanner scanner =new Scanner(System.in);
        double r = scanner.nextDouble();
        double h = scanner.nextDouble();
        double s=((PI*r*r)*2+(PI*2*r*h));
        System.out.printf("%.2f",s);
    }
}

1012

#include
#include 
int main(void){
	double a;
	scanf("%lf",&a);
	double c=fabs(a);
	printf("%.2f",c);
}
 
import java.util.Scanner;
import static java.lang.Math.abs;
public class Main{
    public static void main(String[] args){
        Scanner scanner =new Scanner(System.in);
        double a = scanner.nextDouble();
        double c = abs(a);
        System.out.printf("%.2f",c);
    }
}

1013

#include
#include 
int main(void){
	double x1,y1,x2,y2;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	double a= sqrt(pow(x1-x2,2)+pow(y1-y2,2));
	printf("%.2f",a);
}
import java.util.Scanner;

import static java.lang.Math.*;

public class Main{
    public static void main(String[] args){
        Scanner scanner =new Scanner(System.in);
        double x1 = scanner.nextDouble();
        double y1 = scanner.nextDouble();
        double x2 = scanner.nextDouble();
        double y2 = scanner.nextDouble();
        System.out.printf("%.2f",sqrt(pow(x1-x2,2)+pow(y1-y2,2)));
    }
}

1014

#include
#include 
int main(void){
	double a,b,c;
	scanf("%lf %lf %lf",&a,&b,&c);
	double d = (a+b+c)/2;
	double e =sqrt(d*(d-a)*(d-b)*(d-c));
	printf("%.2f",e);
}
 
import java.util.Scanner;
import static java.lang.Math.*;
public class Main{
    public static void main(String[] args){
        Scanner scanner =new Scanner(System.in);
        double a = scanner.nextDouble();
        double b = scanner.nextDouble();
        double c = scanner.nextDouble();
        double d=(a+b+c)/2;
        double e=sqrt(d*(d-a)*(d-b)*(d-c));
        System.out.printf("%.2f",e);
    }
}

1015

#include
#include 
int main(void){
	int a,b,c;
	scanf("%d:%d:%d",&a,&b,&c);
	int a1,b1,c1;
	scanf("%d:%d:%d",&a1,&b1,&c1);
	int a2,b2,c2;
		a2=(a1-a)*3600;
		b2=(b1-b)*60;
		c2=(c1-c);
	int s =a2+b2+c2;
	printf("%d",s);
	return 0;
}

1016

#include
#include 
double sum(double a){
	return a+a*0.0225;
}
int main(void){
	double m,y;
    scanf("%lf%lf",&y,&m);
    for(int i=1;i<=y;i++){
		m=sum(m);
	}
	printf("%.6f",m);
}
 

1017

#include
#include 
int main(void){
	int n;
	scanf("%d",&n);
	int a=log10(n)+1;
	printf("%d",a);
}
 

1018

#include
#include 
int main(void){
	int n;
	scanf("%d",&n);
	n=fabs(n);
	if(n%2==0){
		printf("%s","even");
	}else{
		printf("%s","odd");
	}
}
 

1019

#include
#include 
int main(void){
	int n;
	scanf("%d",&n);
	int s;
	if(n>=30){
		s=n*48;
	}else{
		s=n*50;
	}
	printf("%d",s);
}
 

1020

#include
#include 
int main(void){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a>b){
		printf("%d %d",b,a);
	}else{
		printf("%d %d",a,b);
	}
}
 

1021

#include
#include 
int main(void){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b&&a>c){
		printf("%d",a);
	}else if(b>a&&b>c){
		printf("%d",b);
	}else{
		printf("%d",c);
	}
	return 0;
}
 

1022

#include
#include 
int main(void){
    int a[3];
    int length= sizeof(a)/sizeof(int);
    for(int i=0;i<length;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<length-1;i++){
        for(int j=i+1;j<length;j++){
            if(a[i]<a[j]){
                int temp =a[i];
                a[i]=a[j];
                a[j]=temp;
            }
        }
    }
    for(int i=0;i<length;i++){
        printf("%d ",a[i]);
    }
    return 0;
}

1023

#include
int main(void){
	char c;
	scanf("%c",&c);
	if(c>'A'&&c<'Z'){
		printf("%c",c);
		return 0;
	}
	c=c-32;
	printf("%c",c);
	return 0;
} 

1024

#include 
int main(){
	char ch;
	scanf("%c",&ch);
	int n;
	if(ch>='a'&&ch<='z'){
		n=ch-96;
	}
	if(ch>='A'&&ch<='Z'){
		n=ch-64;
	}
	printf("%d",n);
}

1025

#include 
int main(){
	char ch1,ch2,ch3;
	scanf("%c %c %c",&ch1,&ch2,&ch3);
	if(ch1>ch2&&ch1>ch3){
		printf("%c",ch1);
	}else if(ch2>ch1&&ch2>ch3){
		printf("%c",ch2);
	}else{
		printf("%c",ch3);
	}
}

1026

#include 
int main(){
	char ch;
	scanf("%c",&ch);
	if(ch>='a'&&ch<='z'){
		printf("lower");
	}else if(ch>='A'&&ch<='Z'){
		printf("upper");
	}else if(ch>='0'&&ch<='9'){
		printf("digit"); 
	}else{
		printf("other");
	}
	return 0;
}

1027

#include 
#include
int main(){
	int n;
	scanf("%d",&n);
	int a,b,c,d;
	d=n;
	c=n%10;
	n=n/10;
	b=n%10;
	n=n/10;
	a=n;
	if(d==pow(c,3)+pow(b,3)+pow(a,3)){
		printf("yes");
	}else{
		printf("no");
	}
}

1028

#include 
#include
int main(){
	int n;
	scanf("%d",&n);
	if(n%400==0||((n%100!=0)&&(n%4==0))){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

1029

#include 
#include
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if((a+b>c)&&(a+c>b)&&(b+c>a)){
		printf("Yes");
	}else{
		printf("No");
	}
}

1030

#include 
#include
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if((a*a+b*b==c*c)||(a*a+c*c==b*b)||(b*b+c*c==a*a)){
		printf("yes");
	}else{
		printf("no");
	}
}

1031

#include 
#include
int main(){
	int x,y;
	scanf("%d%d",&x,&y);
	if(x>0&&y>0){
		printf("1");
	}else if(x<0&&y>0){
		printf("2");
	}else if(x<0&&y<0){
		printf("3");
	}else{
		printf("4");
	}
}

1032

#include 
#include
int main(){
	int x;
	double m;
	scanf("%d",&x);
	if(x<10000){
		m=1500+x*0.05;
	}else if(x<50000){
		m=1500+10000*0.05+(x-10000)*0.03;
	}else{
		m=1500+10000*0.05+40000*0.03+(x-50000)*0.02;
	}
	printf("%.2f",m);
}

1033

#include 
#include
int main(){
	int x;
	scanf("%d",&x);
	if(x>=90){
		printf("A");
	}else if(x>=80){
		printf("B");
	}else if(x>=70){
		printf("C");
	}else if(x>=60){
		printf("D");
	}else{
		printf("E");
	}
}

1034

#include 
#include
int main(){
	double x;
	scanf("%lf",&x);
	if(x<500){
		printf("%.2f",x);
	}else if(x<1000){
		printf("%.2f",x*0.95);
	}else if(x<3000){
		printf("%.2f",x*0.9);
	}else if(x<5000){
		printf("%.2f",x*0.85);
	}else{
		printf("%.2f",x*0.8);
	}
	return 0;
}

1035

#include 
#include
int main(){
	int x;
	scanf("%d",&x);
	if(x<-2){
		printf("%d",7-2*x);
	}else if(x<3){
		int a =fabs(3*x+2);
		printf("%d",5-a);
	}else{
		printf("%d",3*x+4);
	}
}

1036

#include 
#include
int main(){
	int y,m,d;
	scanf("%d%d",&y,&m);
	if(y%400==0||((y%100!=0)&&(y%4==0))){
		if(m==2){
			printf("%d",29);
		}else if(m==1||m==3||m==5||m==7||m==8||m==10||m==12){
		printf("%d",31);
		}else if(m==4||m==6||m==8||m==11){
		printf("%d",30);
		}
	}else if(m==2){
		printf("%d",28);
	}else if(m==1||m==3||m==5||m==7||m==8||m==10||m==12){
		printf("%d",31);
	}else if(m==4||m==6||m==8||m==11){
		printf("%d",30);
	}
}

1037

#include 
#include
int main(void){
	double a,b,c;
	char ch;
	scanf("%lf %c %lf",&a,&ch,&b);
	switch(ch){
		case '+':
			c=a+b;
			printf("%.2f",c);
			break;
		case '-':
			c=a-b;
			printf("%.2f",c);
			break;
		case '*':
			c=a*b;
			printf("%.2f",c);
			break;
		case '/':
			c=a/b;
			if(fabs(b)<1e-10){
				printf("Wrong input!");
			}else{
				printf("%.2f",c);
			}
			break;
		default:
			printf("Wrong input!");
			break;
	}
	return 0;
}

1038

#include 
#include
int main(void){
	int a,b,c;
	int a1,b1,c1;
	scanf("%d%d%d",&a,&b,&c);
	a1=a;
	b1=b;
	c1=c;
	a=fabs(a);
	b=fabs(b);
	c=fabs(c);
	if(a>=b&&a>=c){
		printf("%d",a1);
	} else if(b>=a&&b>=c){
		printf("%d",b1);
	}else{
		printf("%d",c1);
	}
	return 0;
}

1039

#include 
#include
int main(void){
	int n;
	scanf("%d",&n);
	int s=0;
	int temp;
	for(int i=1;i<=n;i++){
		scanf("%d",&temp);
		s=s+temp;
	}
	printf("%d",s);
	return 0;
}

1040

#include 
#include
int main(void){
	int n;
	scanf("%d",&n);
	double s=0;
	double j=1;
	for(int i=1;i<=n;i++){
		s=s+(1/j); 
		j=j+2;
	}
	printf("%.2f",s);
	return 0;
}

1041

#include 
#include
int main(void){
	int n;
	scanf("%d",&n);
	double s=0;
	double j=1;
	for(int i=1;i<=n;i++){
		if(i%2==1){
			s=s+(1/j); 
			j=j+2;
		}else{
			s=s-(1/j);
			j=j+2;
		}

	}
	printf("%.2f",s);
	return 0;
}

1042

#include 
#include
int main(void){
	int n;
	scanf("%d",&n);
	double s=0;
	double j=1;
	for(int i=1;i<=n;i++){
		if(i%2==1){
			s=s+(i/j); 
			j=j+2;
		}else{
			s=s-(i/j);
			j=j+2;
		}

	}
	printf("%.3f",s);
	return 0;
}

1043

#include 
#include
int main(void){
	int n;
	scanf("%d",&n);
	int max=0;
	int temp;
	for(int i=1;i<=n;i++){
		scanf("%d",&temp);
		if(i==1){
			max=temp;
		}
		if(i>1){
			if(max<temp){
				max=temp;
			}
		}
	}
	printf("%d",max);
}

1044

#include 
#include
int main(void){
	int n;
	scanf("%d",&n);
	double s=0;
	double k=0;
	int temp;
	for(int i=1;i<=n;i++){
		scanf("%d",&temp);
		if(temp<60){
			k++;
		}
		s++;
	}
	printf("%.2f",k/s);
	return 0;
}

1045

#include
int main()
{   
    int n,f=0,l=0,z=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int temp;
        scanf("%d",&temp);
        if(temp<0){
            f++;
        }else if(temp==0){
            l++;
        }else{
            z++;
        }
    }
    printf("%d %d %d",f,l,z);
    return 0;
}

1046

#include 
#include
int main(void){
    int n;
    scanf("%d",&n);
    int s=1;
    int temp;
    for(int i=1;i<=n;i++){
        scanf("%d",&temp);
        if(temp%2!=0){
            s=s*temp;   
        }
    }
    printf("%d",s);
    return 0;
}
 

1047

#include 
#include
int main(void){
    int m,n;
    scanf("%d%d",&m,&n);
    for(int i=m;i<=n;i++){
        printf("%4d",i);
        printf("%8.4f\n",log(i));
    }
}
 

1048

#include 
#include
int main(void){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		double m=1;
		for(int j=1;j<=i;j++){
			m=m*j;
		}
		printf("%-4d%-20.0f\n",i,m);
	}
	return 0;
}

1049

#include 
#include
int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	long long int s1=0,s2=0;
	for(int i=n;i<=m;i++){
		if(i%2==0){
			s1=s1+i*i;
		}else{
			s2=s2+pow(i,3);
		}
	}
	printf("%d %d",s1,s2);
	return 0;
}

1050

#include 
#include
int main(void){
	int n;
	long long int s=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		long long int k=1;
		for(int j=1;j<=i;j++){
			k=k*j;
		}
		s=s+k;
	}
	printf("%d",s);
}

1051

#include 
#include
int main(void){
	int n,m;
	scanf("%d %d",&n,&m);
	double s=0;
	double temp=n;
	for(int i=1;i<=m;i++){
		s=s+temp;
		temp=sqrt(temp);
	}
	printf("%.2f",s);
}

1052

#include
#include
int main(void){
	int n,a;
	scanf("%d%d",&n,&a);
	int s=0;
	for(int i=1;i<=n;i++){
		int temp=0;
		for(int j=1;j<=i;j++){
			temp=temp*10+a;
		}
		s=s+temp;
	}
	printf("%d",s);
}

1053

#include
int main()
{   
	double x;
	scanf("%lf",&x);
	double s=0;
	double d=x;
	double a=1;
	double j=1;
	for(int i=1;i<=10;i++){
		s=s+a*d/j;
		j=j*(2*i)*(2*i+1);
		a=-a;
		d=d*x*x;
	}
	printf("%.3f",s);
	return 0;
}
 

1054

#include
int main()
{   
	int n;
	scanf("%d",&n);
	int d=1;
	for(int i=1;i<n;i++){
		d=(d+1)*2;
	}
	printf("%d",d);
	return 0;
}
 

1055

#include
int main()
{   
	int n;
	scanf("%d",&n);
	if(n==1||n==2){
		printf("1");
		return 0;
	}
	int s=0;
	int x=1,y=1;
	for(int i=3;i<=n;i++){
		s=x+y;
		x=y;
		y=s;
	}
	printf("%d",s);
}
 

1056

#include
int main()
{   
	int m,n;
	scanf("%d%d",&m,&n);
	for(int i=n;i>=m;i--){
		if(i%7==0&&i%4!=0){
			printf("%d",i);
			return 0;
		}
	}
	printf("no");
	return 0;
}


1057

#include
#include
int main(){
	int n;
	scanf("%d",&n);
	if(n==1){
		printf("No");
		return 0;
	}
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}


1058

#include
#include
long long int jc(int n){
	long long int s=1;
	for(int i=1;i<=n;i++){
		s=s*i;
	}
	return s;
}
int main(){
	long long int n;
	scanf("%d",&n);
	long long int s=0;
	for(int i=1;;i++){
		s=s+jc(i);
		if(s>=n){
			printf("m<=%d",i-1);
			return 0;
		}
	}
}

1059

#include
#include
#include
int main(){
	int max=0;
	bool flag=true;
	while(flag){
		int temp;
		scanf("%d",&temp);
		if(temp<0){
			flag=false;
		}else if(max<temp){
			max=temp;
		}
	}
	printf("%d",max);
	return 0;
}

1060

#include
#include
#include
int main(){
	int n;
	scanf("%d",&n);
	while(n>0){
		printf("%d ",n%10);
		n=n/10;
	}
	return 0;
}

1061

#include
#include
#include
int main(){
	int n;
	int a[10];
	scanf("%d",&n);
	int i=0;
	while(n>0){
		a[i]=n%10;
		i++;
		n=n/10;
	}
	for(int j=i-1;j>=0;j--){
		printf("%d ",a[j]);
	}
	return 0;
}

1062

#include
#include
#include
int main(){
	int m,n;
	scanf("%d%d",&m,&n);
	while(m%n!=0){
		int r;
		r=m%n;
		m=n;
		n=r;
	}
	printf("%d",n);
	return 0;
}

1063

#include
#include
int main(){
	int m,n;
	scanf("%d%d",&m,&n);
	double a,b;
	a=m;
	b=n;
	while(m%n!=0){
		int r;
		r=m%n;
		m=n;
		n=r;
	}
	double c=n;
	double s=a*b/c;
	printf("%d %.0f",n,s);
	return 0;
}

1064

#include
#include
#include
int main(){
	bool flag=true;
	while(flag){
		char ch;
		scanf("%c",&ch);
		if(ch=='@'){
			flag=false;
			break;
		}else if(ch>='A'&&ch<='Z'){
			ch=ch+32;
		}
		if(ch>='a'&&ch<='y'){
			ch=ch+1;
		}else if(ch=='z'){
			ch='a';
		}
		printf("%c",ch);
	}
	return 0;
}

1065

#include
#include
#include
int main(){
	bool flag=true;
	int s=0;
	while(flag){
		char ch;
		scanf("%c",&ch);
		if(ch=='\n'){
			break;
		}
		if(ch>='0'&&ch<='9'){
			s++;
		}
	}
	printf("%d",s);
	return 0;
}

1066

#include
#include
#include
int main(){
	bool flag=true;
	int l=0,d=0,o=0;
	while(flag){
		char ch;
		scanf("%c",&ch);
		if(ch=='\n'){
			break;
		}
		if(ch>='0'&&ch<='9'){
			d++;
		}else if(ch>='a'&&ch<='z'||(ch>='A'&&ch<='Z')){
			l++;
		}else{
			o++;
		}
	}
	printf("letter:%d\n",l);
	printf("digit:%d\n",d);
	printf("other:%d",o);
	return 0;
}

1067

#include
#include
#include
int main(){
	int n;
	scanf("%d",&n);
	int x=0;
	for(int i=1;i<=n;i++){
		if(i%10==4)continue;
		if(i/10%10==4)continue;
		if(i/100==4)continue;
		x++;
	}
	printf("%d",x);
	return 0;
}

1068

#include
#include
#include
int main(){
	int d=0;
	char ch;
	while(ch=getchar(),ch!='\n'){
		d=d*2+(ch-'0');
	}
	printf("%d",d);
	return 0;
}

1069

#include
#include
#include
int main(){
	int M,k,i;
	scanf("%d%d",&M,&k);
	for(i=1;i<=M;i++){
		if(i%k==0){
			M++;
		}
	}
	printf("%d",i-1);
	return 0;
}

1070

#include
#include
#include
int main(){
	bool flag=true;
	int i=1;
	int h,m,f=0;
	int x=0,y=0;
	int h1=0;
	while(flag){
		int temp;
		scanf("%d",&h);
		scanf("%d",&m);
		temp=h;
		h=h-h1;	
		h1=temp;
		if(f==0){
			y=y+h*10;	
		}
		if(f==1){
			x=x-h*10;
		}
		if(f==2){
			y=y-h*10;
		}
		if(f==3){
			x=x+h*10;
		}
		if(m==1){
			f=(f+1)%4;
		}
		if(m==2){
			f=(f-1)%4;
		}
		f=(f+4)%4;
		if(m==3){
			flag=false;
		}
		
	}
	printf("%d %d",x,y);
	return 0;
}

1071

# include
int main(){
	int n;
	scanf("%d",&n);
	for(int i=2;i<=n;){
		if(n%i==0){
			printf("%d",i);
			if(n/i!=1){
			printf(" ");
			}
			n=n/i;
		}else{
			i++;
		}
	}
	return 0;
}

1072

# include
int main(){
	int high,up,down;
	scanf("%d%d%d",&high,&up,&down);
	int s=up;
	int i=1;
	for(;;i++){
		if(s>high){
			break;
		}else{
			s=s+up-down;
//			printf("-%d-\n",s);
		}
		
	}
	printf("%d",i-1);
}

1073

# include
int main(){
	int head,foot;
	scanf("%d%d",&head,&foot);
	int j=0,t=0;
	for(int j=1;j<=head;j++){
		if(2*j+4*(head-j)==foot){
			printf("%d %d",j,head-j);
			return 0;
		}
	}
	printf("No Answer");
	return 0;
}

1074

#include
int main (){
	int a=1;
	double n;
	scanf("%lf",&n);
	for(int i=0;i<=n/5;i++){
		for(int j=0;j<=n/3;j++){
			for(double k=0;k<=n*3;k++){
				if(i+j+k==n&&(5*i+3*j+k/3==n)){
					printf("%4d%4d%4.0f\n",i,j,k);
					a=0;
				}
			}
		}
	}
	if(a==1){
		printf("No Answer");
	} 
	return 0;
} 

1075

#include
int main (){
	int n,cost;
	scanf("%d%d",&n,&cost);
	int a=1;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				if(i+j+k==n&&(3*i+2*j+k==cost)){
					printf("%d %d %d\n",i,j,k);
					a=0;
				}
			}
		}
	}
	if(a==1){
		printf("No answer");
	}
	return 0;
}  

1076

#include
int main (){
	int n;
	scanf("%d",&n);
	int a=1;
	for(int x=1;x<=9;x++){
		for(int y=1;y<=9;y++){
			for(int z=0;z<=9;z++){
				if((x*100+y*10+z)+(y*100+z*10+z)==n){
					printf("%4d%4d%4d",x,y,z);
					a=0;
				}
			}
		}
	}
	if(a==1){
		printf("No Answer");
	}
	return 0;
}  

1077

#include
int main (){
	int n;
	scanf("%d",&n);
	int a=1;
	for(int i=1;i<2*n;i++){
		if(i<=n){
			for(int j=1;j<=n-i;j++){
				printf(" ");
			}
			printf("*");
			if(i>=2){
				for(int k=1;k<=a;k++){
					printf(" ");
				}
				a=a+2;
			}
			if(i!=1){
				printf("*");
			}
			printf("\n");
		}else{
			for(int j=1;j<=i-n;j++){
				printf(" ");
			}
			printf("*");
			if(i==n+1){
				a=a-4;
			}else{
				a=a-2;
			}
			for(int k=1;k<=a;k++){
				printf(" ");
			}
			if(i!=2*n-1){
				printf("*");
			}
			printf("\n");
		}
	}
}  

1078

#include
int main (){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		printf("%d\n",a+b);
	}
	return 0;
}  

1079

#include
int main (){
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF){
		printf("%d\n",a+b);
	} 
	return 0;
}  

1080

#include
int main (){
	int a,b;
	while(scanf("%d%d",&a,&b),a!=0||b!=0){
		printf("%d\n",a+b);
	} 
	return 0;
}  

1081

#include
int main (){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int temp;
		int s=0;
		scanf("%d",&temp);
		for(int j=1;j<=temp;j++){
			int a;
			scanf("%d",&a);
			s=s+a;
		}
		printf("%d\n",s);
	}
	return 0;
}  

1082

#include
int main (){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int temp;
		scanf("%d",&temp);
		for(int j=7;j<=temp;j++){
			if(j==7){
				printf("%d ",j);
				continue;
			}else if(j%7==0){
				printf("%d ",j);
			}else{
				int a=j;
				while(a>=7){
					if(a%10==7){
						printf("%d ",j);
						break;
					} 
					a=a/10;
				}	
			}
			
		}
		printf("\n");
	}
	return 0;
}  

1083

#include
int main (){
	int n;
	while(scanf("%d",&n),n!=0){
		int f=0,l=0,z=0;
		double x;
		for(int i=1;i<=n;i++){
			scanf("%lf",&x);
			if(x<0){
				f++;
			}else if(x==0){
				l++;
			}else{
				z++;
			}
		}
		printf("%d %d %d\n",f,l,z);
	}
	return 0;
}  

1084

#include
#include
int main (){
	double x1,y1,x2,y2;
	while(scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2)!=EOF){
		double s;
		s=sqrt(pow(x1-x2,2)+pow(y1-y2,2));
		printf("%.2f\n",s);
	}
	return 0;
}  

1085

#include
#include
int main (){
	int n;
	while(scanf("%d",&n)!=EOF){
		int s=1;
		int a;
		for(int i=1;i<=n;i++){
			scanf("%d",&a);
			if(a%2!=0){
				s=s*a;
			}
		}
		printf("%d\n",s);
	}
	return 0;
}  

1086

#include
#include
int main (){
	char a,b,c;
	while(scanf("%c%c%c",&a,&b,&c)!=EOF){
		getchar();
		char temp,q,w,e;
		if(a<b&&a<c){
			q=a;
			if(b<c){
				w=b;
				e=c;
			}else{
				w=c;
				e=b;
			}
		}else if(b<a&&b<c){
			q=b;
			if(a<c){
				w=a;
				e=c;
			}else{
				w=c;
				e=a;
			}
		}else{
			q=c;
			if(a<b){
				w=a;
				e=b;
			}else{
				w=b;
				e=a;
			}
		}
		printf("%c %c %c\n",q,w,e);
	} 
	return 0;
}  

1087

#include
#include
int main (){
int n;
scanf(“%d”,&n);
int a,b,c,d,e;
for(int i=1;i<=n;i++){
scanf(“%6d%4d%2d%2d%4d”,&a,&b,&c,&d,&e);
printf(“%d-%02d-%02d\n”,b,c,d);
}
return 0;
}

1088

#include
#include
int main (){
	int n;
	scanf("%d",&n);
	int a,b;
	for(int i=1;i<=n;i++){
		scanf("%6d%5d",&a,&b);
		printf("6%05d\n",b);
	}
	return 0;
}  

1089

#include
#include
int main (){
	int n;
	scanf("%d",&n);
	double s=1;
	while(n>1){
		s=s*n;
		while(s>10){
			s=s/10;
		}
		n--;
	}
	printf("%d",(int)s);
	return 0;
}  

1090

#include
#include
int main (){
    int n;
    scanf("%d",&n);
    while(n>0){
        int a,b;
        scanf("%d%d",&a,&b);
        int s=1;
        while(b>0){
        	s=s*a;
        	s=s%1000;
        	b--;
		}
		n--;
		printf("%d\n",s); 
    }
    return 0;
}

1091

#include
#include
int main (){
	int n;
	int s=0;
	while(scanf("%d",&n),n!=0){
		if(n==1){
			printf("1\n");
		}else if(n==2){
			printf("2\n");
		}else{
			int a=1;
	        int b=2;
			while(n>2){
				
				s=a+b;
				a=b;
				b=s;
				n--;
			}
			printf("%d\n",s);
		}
	}
	return 0;
}

1092

# include
# include
int prime(int n) 
{ 
	if(n==1){
		return 0;
	}
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0){
			return 0;
		}
	}
	return 1;
} 
int main(void){
	int m,n;
	scanf("%d%d",&m,&n);
	for(int i=m;i<=n;i++){
		int a=prime(i);
		if(a==1){
			printf("%d ",i);
		}
	}
	return 0;
}

1093

# include
# include
int prime(int n) 
{ 
	if(n==1){
		return 0;
	}
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0){
			return 0;
		}
	}
	return 1;
} 
int main(void){
	int m;
	scanf("%d",&m);
	for(int i=1;i<=m/2;i++){
		int a=prime(i);
		int b=prime(m-i);
		if(a==1&&b==1){
			printf("%d %d\n",i,m-i);
		}
	}
	return 0;
}

1094

# include
int vowel(char ch)
{
    switch(ch){
    	case 'a':
    		return 1;
    	case 'A':
    		return 1;
    	case 'e':
    		return 1;
    	case 'E':
    		return 1;
    	case 'i':
    		return 1;
    	case 'I':
    		return 1;
    	case 'o':
    		return 1;
    	case 'O':
    		return 1;
    	case 'u':
    		return 1;
    	case 'U':
    		return 1;
    	default:
    		return 0;
	}
}
int main (void){
	char ch;
	int sum =0;
	while(scanf("%c",&ch),ch!='\n'){
		int a=vowel(ch);
		if(a==1){
			sum=sum+1;
		}
	}
	printf("%d",sum);
	return 0; 
}

1095

//把时分秒转换成秒并返回, 三个参数分别为用于表示一个时间点的时、分、秒
int HmsToS(int h, int m, int s){
	long long int a;
	a=h*3600+m*60+s;
	return a;
	}
//将时间段转换为对应的“小时:分钟:秒” 格式输出 ,形参s表示一个时间段的长度,单位是秒
void PrintTime(int s){
	int a;
	a=s/3600;
	s=s-a*3600;
	int b=s/60;
	s=s-b*60;
	int c=s;
	printf("%02d:%02d:%02d\n",a,b,c);
	}

1096

#include
int narcissus(int n){
	int a,b,c;
	int d=n;
	a=n%10;
	n=n/10;
	b=n%10;
	n=n/10;
	c=n;
	if(d==a*a*a+b*b*b+c*c*c){
		return 1;
	}
	return 0;
}
int main(){
	int m,n;
	while(scanf("%d%d",&m,&n)!=EOF){
		int flag=0;
		for(int i=m;i<=n;i++){
			int d=narcissus(i);
			if(d==1&&flag==0){
				printf("%d",i);
				flag=1;
			}else if(d==1&&flag==1){
				printf(" %d",i);
			}
		}
		if(flag==0){
			printf("no");
		}
		printf("\n");
	}
	return 0;
}

1097

# include
int getScore(char g)
{ 
//把等级g转换成对应的分数并返回这个分数。 
	switch(g){
		case 'A':
			return 95;
		case 'B':
			return 85;
		case 'C':
			return 75;
		case 'D':
			return 65;
		case 'E':
			return 40;
	}
}
int main(){
	int i=0;
	char ch;
	double sum=0;
	while(scanf("%c",&ch),ch!='\n'){
		int a=getScore(ch);
		sum=sum+a;
		i++; 
	}
	printf("%.1f",sum/i);
	return 0;
}

1098

# include
# include
double funF(double x)
{
//函数返回F(x)的值;
	return fabs(x-3)+fabs(x+1);
}
double funG(double x)
{
//函数返回G(x)的值;
	return pow(x,2)-3*x;
}

1099

# include
# include
int main(void){
	int n;
	while(scanf("%d",&n)!=EOF){
		int i=0;
		while(n!=1){
			if(n%2==0){
				n=n/2;
				i++;
			}else{
				n=n*3+1;
				i++;
			}
		}
		printf("%d\n",i);
	}
	return 0;
}

1100

# include
# include
int fact(int n){
	int s=1;
	for(int i=1;i<=n;i++){
		s=s*i;
	}
	return s;
}
int main (){
	int m,n;
	scanf("%d%d",&m,&n);
	int a,b,c;
	a=fact(m);
	b=fact(n);
	c=fact(m-n);
	printf("%d\n",a/(b*c));
	return 0;
}

1101

int inverse(int n)
{
//计算并返回n的逆序数字
	int sum=0;
	int flag=0;
	for(int i=1;n>0;i++){
		sum=sum*10+n%10;
		n=n/10;
	}
	return sum;
}

1102

#include
double CancelFee(double price){
	double a=price*0.05;
//	printf("%f\n",a);
	int d=a*100;
//	printf("%d\n",d);
	double s=d%100;
//	printf("%d\n",s);
	if(s<25){
		s=0;
	}else if(s<75){
		s=0.5;
	}else{
		s=1;
	}
//	printf("%d\n",d/100);
//	printf("%f\n",s);
	return d/100+s;
}
int main(){
	int n;
	scanf("%d",&n);
	CancelFee(n);
	return 0;
}

1103

# include
int facsum(int n)
{
//计算n的所有正因子(包括1,不包括自身)之和sum,本函数返回sum 
	int sum=0;
	for(int i=1;i<n;i++){
		int a=n/i;
		if(a*i==n){
			sum=sum+i;
		}
	}
	return sum;
}
int main(){
	int m,n;
	int z=0;
	scanf("%d%d",&m,&n);
	int d=m;
	while(d<=n){
		int s=facsum(d);
		int a=facsum(s);
		if(d==a&&d<s){
			printf("%d %d\n",d,s);
			z=1;
		} 
		d++;
	}
	if(z==0){
		printf("No answer");
	}
	return 0;
}

1104

# include

int huiwen(int n){
	int s=0;
	while(n>0){
		int a=n%10;
		s=s*10+a;
		n=n/10;
	}
	return s;
}

int main(){
	int m,n;
	scanf("%d%d",&m,&n);
	for(int i=m;i<=n;i++){
		int a=huiwen(i);
		if(i==a){
			printf("%d ",i);
		} 
	}	
	return 0;
}

1105

1106

1107

# include

int inverse(int n){
	int s=0;
	while(n>0){
		int a=n%10;
		s=s*10+a;
		n=n/10;
	}	
	return s;
}
int main(){
	int n;
	int f=1;
	int m;
	scanf("%d",&n);
	while( m = inverse(n), m != n)
	{
		if(f==1){
			printf("%d ",n);	
		}
	    n= m + n;
	}
	printf("%d",n);
	return 0;
}


1108

# include

 void PrintDigit(int m){
 	for(int i=1;i<=m;i++){
 		printf("%d",i);
	 }
	 for(int i=m-1;i>0;i--){
	 	printf("%d",i);
	 }
	 printf("\n");
 }
 void PrintSpace(int m){
 	for(int i=1;i<=m;i++){
	 	printf(" ");
	 }
 }
 int main(){
 	int n;
 	scanf("%d",&n);
 	for(int i=1;i<=n;i++){
 		PrintSpace(n-i);
 		PrintDigit(i);
	 }
  	for(int i=n-1;i>=1;i--){
		PrintSpace(n-i);
		PrintDigit(i);
    }
 }

1109

# include
int digitSum(int n)
{
//函数返回n的各位数字之和
	int sum=0;
	while(n>0){
		sum=sum+n%10;
		n=n/10;
	} 
	return sum;
} 
int main(){
	int n;
	scanf("%d",&n);
	int f=digitSum(n);
	while(f>10){
		f=digitSum(f);
	}
	printf("%d",f);
	return 0;	
}

1110

# include
int common(int x, int y)
{
//如果x==y, return x;
//如果x>y,求x/2与y的共同祖先;
//否则,求x与y/2的共同祖先;
	while(x!=y){
		if(x>y){
			x=x/2;
		}else{
			y=y/2;
 		}
	}
	return x; 
}
int main(){
	int x,y;
	scanf("%d%d",&x,&y);
	x=common(x,y);
	printf("%d\n",x);
	return 0;
}

1111

# include
void inverse(int n)
{
//读入一个整数,存入num;
	int num;
	scanf("%d",&num);
    if(n >1)
       {
//          将后面的n-1个数逆序输出: inverse(n-1);
		  inverse(n-1);
          printf("%d ",num);
      }
      if( n == 1){
      	printf("%d ",num);
	  }
}
int main(void){
	int n;
	scanf("%d",&n);
	inverse(n);
	return 0;
}

1112

# include
void convert(int n)
{
   if(n > 0)
   {
   		convert(n/2);
   		int a=n%2;
   		printf("%d",a);
    }
}

int main(){
	int n;
	scanf("%d",&n);
	convert(n);
	return 0;
}

1113

#include
int fib(int k);
int s=0;
int main()
{
    int n;
    scanf("%d", &n);
    printf("%d\n", fib(n));  
    printf("递归调用了%d次",s);
    return 0;
}

int fib(int k)
{
	s++;
    if(k == 1 || k == 2)
        return 1;
    else
        return fib(k-1) + fib(k-2);
}

1114

#include
void nixu(int n){
	int num;
	scanf("%d",&num);
	if(n==1){
		printf("%4d",num);
		n=n-1;
	}
	if(n>1){
		n=n-1;
		nixu(n);
		printf("%4d",num);
	}
} 
int main(){
	int n;
	scanf("%d",&n);
	nixu(n);
	return 0;
}

你可能感兴趣的:(算法帝国,算法)