2021/2/22 CCF练习201612(c++)

201612-1

#include <iostream>
using namespace std;
int a[1000];
int main()
{
    
    
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	int lnum=0,rnum=0;
	int mid=0;
	for(int i=0;i<n;i++)
	{
    
    
		for(int j=0;j<n;j++)
		{
    
    
			if(a[j]<a[i])
				lnum++;
			else if(a[j]>a[i])
				rnum++;
			else
				;
		}
		if(lnum==rnum)
			mid=a[i];
		lnum=rnum=0;
	}
	if(mid!=0)
		cout<<mid<<endl;
	else
		cout<<"-1"<<endl;
	return 0;
}

201612-2

#include <iostream>
using namespace std;
#define MAX 200000
int main()
{
    
    
	int s,t;
	cin>>t;
	if(t<=3500)
		cout<<t<<endl;
	else
	{
    
    
		for(int s=3600;s<MAX;s+=100)
		{
    
    
			int A=s-3500;
			int tax=0;
			if(A>1500) tax+=1500*0.03;
			else {
    
    tax+=A*0.03;goto end;}
			if(A>4500) tax+=3000*0.10;
			else {
    
    tax+=(A-1500)*0.10;goto end;}
			if(A>9000) tax+=4500*0.20;
			else {
    
    tax+=(A-4500)*0.20;goto end;}
			if(A>35000) tax+=26000*0.25;
			else {
    
    tax+=(A-9000)*0.25;goto end;}
			if(A>55000) tax+=20000*0.30;
			else {
    
    tax+=(A-35000)*0.30;goto end;}
			if(A>80000) tax+=25000*0.35;
			else {
    
    tax+=(A-55000)*0.35;goto end;}
			tax+=(A-80000)*0.45;

end:
			if(s-tax==t)
				{
    
    
					cout<<s<<endl;
					break;
			}
		}
	}

	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_40395925/article/details/113944282
今日推荐