信奥赛例题——1132,1166,1167,1186

   1132
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
	int N;
	cin>>N;
	string S1,S2;
	string x="Rock",y="Scissors",z="Paper";
	for(int i=0;i<N;i++){
		cin>>S1>>S2;
		if(S1==S2){
			cout<<"Tie"<<endl;
		}else if(S1=="Rock" && S2=="Scissors"){
			cout<<"Player1"<<endl;
		}else if(S1==x && S2==z){
			cout<<"Player2"<<endl;
		}else if(S1==y && S2==z){
			cout<<"Player1"<<endl;
		}else if(S1==z && S2==x){
			cout<<"Player1"<<endl;
		}else if(S1==y && S2==x){
			cout<<"Player2"<<endl;
		}else if(S1==z && S2==y){
			cout<<"Player2"<<endl;
		}
	}
	return 0;
}
      1166
//递归      
#include <bits/stdc++.h>
using namespace std;
double a(double n,double x){
	if(n==1){
		return sqrt(n+x);
	}
	return sqrt(n+a(n-1,x));
}
int main(int argc, char** argv) {
	double n,x;
	cin>>n>>x;
	cout<<fixed<<setprecision(2)<<a(x,n);
	return 0;
}
//递推 
#include <bits/stdc++.h>
using namespace std;
int main(){
	int f,n,x;
	cin>>n>>x;
	f=sqrt(n+x);	
	for(int i=2;i<n;i++){
		f=sqrt(i+y);
	}
	return 0;
}
    1167
#include <bits/stdc++.h>
using namespace std;
double a(double n,double x){
	if(n==1){
		return x/(x+n);
	}
	return x/(n+a(n-1,x));
}
int main(int argc, char** argv) {
	double n,x;
	cin>>n>>x;
	cout<<fixed<<setprecision(2)<<a(x,n);
	return 0;
}
      1186
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
	int n,a[105]={},k;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>k;
		a[k+50]++;
	}
	for(int i=-50;i<=50;i++){
		if(a[i+50]>n/2){
			cout<<i;
			return 0;
		}
	}
	cout<<"no";
	return 0;
}

  

posted @ 2023-08-01 20:02  fushuxuan1  阅读(45)  评论(0)    收藏  举报