PTA L1 031-040

L1-031

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

int main()
{
	int n;
	cin>>n;
	int l,w;
	while(n--){
		cin>>l>>w;
		if( fabs((l-100.0)*0.9-w/2.0) < (l-100.0)*0.9*0.1)
			cout<<"You are wan mei!\n";
		else if((l-100.0)*0.9-w/2.0<0)
			cout<<"You are tai pang le!\n";
		else
			cout<<"You are tai shou le!\n"; 
	}
	return 0;
}

L1-032

#include<iostream>
using namespace std;
int main()
{
	int n;
	char c;
	cin>>n>>c;
	getchar();
	char a[100005];
	int l=0;char temp;
	while(1){
		temp=getchar();
		if(temp=='\n')
			break;
		a[l]=temp;
		l++;
	}
	if(l<=n){
		for(int i=1;i<=n-l;i++)
			cout<<c;
		for(int i=0;i<l;i++)
			cout<<a[i];
	}
	else{
		for(int i=l-n;i<l;i++)
			cout<<a[i];
	}
	return 0;
}

L1-033

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int year,n;
	cin>>year>>n;
	int y=year;
	while(1){
		int temp=year;
		int a[10]={0};
		if(temp<1000)
			a[0]=1;
		while(temp){
			a[temp%10]++;
			temp/=10;
		}
		int nn=0;
		for(int i=0;i<=9;i++)
			if(a[i])
				nn++;
		if(nn==n){
			cout<<year-y<<' ';
			printf("%04d",year);
			return 0;
		}
		year++;
	}
}

L1-034

#include<iostream>
#include<map>
using namespace std;
int main()
{
	int n;
	map<int,int> mp;
	cin>>n;
	while(n--){
		int k;
		cin>>k;
		for(int i=1,temp;i<=k;i++){
			cin>>temp;
			mp[temp]++;
		}
	}
	int maxn=0,maxx=0;
	for(int i=1000;i>=1;i--)
		if(mp[i]>maxx){
			maxx=mp[i];
			maxn=i;
		}
	cout<<maxn<<' '<<maxx;
	return 0;
}

L1-035

#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main()
{
	string s="hhhh";
	vector<string> v;
	while(s[0]!='.'){
		cin>>s;
		v.push_back(s);
	}
	int l=(int)v.size()-1;
	if(l<2){
		cout<<"Momo... No one is for you ...";
	}
	else if(l<14){
		cout<<v[1]<<" is the only one for you...";
	}
	else{
		cout<<v[1]<<" and "<<v[13];
		cout<<" are inviting you to dinner..."; 
	}
	return 0;
}

L1-036

#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<a*b;
	return 0;
}

L1-037

#include<iostream>
using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	cout<<a<<'/';
	if(b<0)
		cout<<'('<<b<<')';
	else
		cout<<b;
	cout<<"=";
	if(b==0)
		cout<<"Error";
	else{
		printf("%.2lf",a*1.0/b);
	}
	return 0;	
}

L1-038

#include<iostream>
using namespace std;
int main()
{
	cout<<"Hello World\nHello New World";
	return 0;
}

L1-039

#include<iostream>
using namespace std;

char a[1005][1005];

int main()
{
	int n;
	cin>>n;
	getchar();
	char c;
	int x=1,y=1000;
	while(1){
		c=getchar();
		if(c=='\n')
			break;
		a[x][y]=c;
		x++;
		if(x==n+1){
			x=1;
			y--;
		}
	}
	if(x!=1){
		for(int j=x;j<=n;j++)
			a[j][y]=' ';
	}
	else
		y++;
	for(int j=1;j<=n;j++){
		for(int i=y;i<=1000;i++)
			cout<<a[j][i];
		cout<<endl;
	}
	return 0;
} 

L1-040

#include<iostream>
using namespace std;

void slove()
{
	char c;
	double h;
	cin>>c>>h;
	if(c=='M'){
		h/=1.09;
	}
	else{
		h*=1.09;
	}
	printf("%.2f\n",h);
}

int main()
{
	int n;
	cin>>n;
	while(n--){
		slove();
	}
	return 0;
 } 

  • 9
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值