【CCCC】PAT : 团体程序设计天梯赛-练习集 L1 答案

【CCCC】PAT : 团体程序设计天梯赛-练习集 L1 答案

鉴定完毕,全部水题 ヾ(•ω•`)o

标号标题分数通过数提交数通过率
L1-001Hello World5467791127780.41
L1-002打印沙漏2020237836550.24
L1-003个位数统计1520404655490.31
L1-004计算摄氏温度524244747810.32
L1-005考试座位号1515518504280.31
L1-006连续因子2011949521720.23
L1-007念数字1016522520750.32
L1-008求整数段和1015060668970.23
L1-009N个数求和209638606670.16
L1-010比较大小1015540385380.40
L1-011A-B2011898479910.25
L1-012计算指数516607473100.35
L1-013计算阶乘和1014480272370.53
L1-014简单题516854240680.70
L1-015跟奥巴马一起画方块1512927347140.37
L1-016查验身份证159851312920.31
L1-017到底有多二1510480381200.27
L1-018大笨钟1011624375160.31
L1-019谁先倒158846293430.30
L1-020帅到没朋友208467432500.20
L1-021重要的话说三遍514685241930.61
L1-022奇偶分家1011361215850.53
L1-023输出GPLT208285220370.38
L1-024后天512956297660.44
L1-025正整数A+B157430443830.17
L1-026I Love GPLT512588310650.41
L1-027出租206968146240.48
L1-028判断素数1011228605520.19
L1-029是不是太胖了511830247620.48
L1-030一帮一157967174980.46
L1-031到底是不是太胖了109399343910.27
L1-032Left-pad207210232800.31
L1-033出生年156747152490.44
L1-034点赞206337131970.48
L1-035情人节157044186440.38
L1-036A乘以B511514181520.63
L1-037A除以B109116251690.36
L1-038新世界510515145960.72
L1-039古风排版206973289870.24
L1-040最佳情侣身高差108786206370.43
L1-041寻找250108703203010.43
L1-042日期格式化59734219540.44
L1-043阅览室205046232340.22
L1-044稳赢156085202150.30
L1-045宇宙无敌大招呼59944205420.48
L1-046整除光棍205555149290.37
L1-047装睡107819150670.52
L1-048矩阵A乘以B155523172810.32
L1-049天梯赛座位分配204474155450.29
L1-050倒数第N个字符串155678133310.43
L1-051打折59542198210.48
L1-0522018我们要赢59616141180.68
L1-053电子汪107799120470.65
L1-054福到了155655171790.33
L1-055谁是赢家106763180260.38
L1-056猜数字206204197320.31
L1-057PTA使我精神焕发5654388800.74
L1-0586翻了154275127870.33
L1-059敲笨钟203528111960.32
L1-060心理阴影面积55290107130.49
L1-061新胖子公式104378100380.44
L1-062幸运彩票15368781920.45
L1-063吃鱼还是吃肉104108109670.37
L1-064估值一亿的AI核心代码202561152610.17

L1-AC代码

L1-001
#include<bits/stdc++.h>
using namespace std;
int main(){
	cout<<"Hello World!";
	return 0;
}

L1-002
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;  char ch;
	cin>>n>>ch;
	int h = sqrt((n+1)/2);
	for(int i = h; i >= 1; i--){
		for(int j = 1; j <= h-i; j++)cout<<" ";
		for(int j = 1; j <= 2*i-1; j++)cout<<ch;
		cout<<"\n";
	}
	for(int i = 2; i <= h; i++){
		for(int j = 1; j <= h-i; j++)cout<<" ";
		for(int j = 1; j <= 2*i-1; j++)cout<<ch;
		cout<<"\n";
	}
	cout<<n+1-2*h*h<<endl;
	return 0;
}

L1-003
#include<bits/stdc++.h>
using namespace std;
int a[110];
int main(){
	string s;  cin>>s;
	for(int i = 0; i < s.size(); i++){
		a[s[i]-'0']++;
	}
	for(int i = 0; i <= 9; i++){
		if(a[i]){
			cout<<i<<":"<<a[i]<<"\n";
		}
	}
	return 0;
}

L1-004
#include<bits/stdc++.h>
using namespace std;
int main(){
	int f, c;
	cin>>f;
	c = 5*(f-32)/9;
	cout<<"Celsius = "<<c<<endl;
	return 0;
}

L1-005
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1100;
string ha[maxn]; int  ha2[maxn];
int main(){
	int n;  cin>>n;
	for(int i = 1; i <= n; i++){
		string a; int b, c;
		cin>>a>>b>>c;
		ha[b] = a;
		ha2[b] = c;
	}
	int q;  cin>>q;
	for(int i = 1; i <= q; i++){
		int x;  cin>>x;
		cout<<ha[x]<<" "<<ha2[x]<<"\n";
	}
	return 0;
}

L1-006
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n;  cin>>n;
	int star=0, len=0;
	int t = sqrt(n)+1;
	for(int i = 2; i <= t; i++){
		int tmp = 1, j;
		for(j = i; j <= t; j++){
			tmp *= j;
			if(n%tmp != 0)break;
		}
		if(j-i>len){
			star = i;
			len = j-i;
		}
	}
	if(star == 0){
		cout<<1<<endl;
		cout<<n<<endl;
	}else{
		cout<<len<<endl;
		for(int i = 0; i < len-1; i++)
			cout<<star+i<<"*";
		cout<<star+len-1;
	}
	return 0;
}

L1-007
#include<bits/stdc++.h>
using namespace std;
string s[11] = {"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};
int main(){
	string a;  cin>>a;
	for(int i = 0; i < a.size(); i++){
		if(i!=0)cout<<" ";
		if(a[i]=='-'){
			cout<<"fu";
			continue;
		}
		cout<<s[a[i]-'0'];
	}
	return 0;
}

L1-008
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b;
	cin>>a>>b;
	int cnt = 0, sum = 0;
	for(int i = a; i <= b; i++){
		printf("%5d",i);
		sum += i;
		cnt++;
		if(cnt%5==0){
			cout<<"\n";
		}
	}
	if(cnt%5!=0)cout<<"\n";
	cout<<"Sum = "<<sum<<"\n";
	return 0;
}

L1-009
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b){return !b?a:gcd(b,a%b);}
int main(){
	int n;  cin>>n;
	int a, b, c=0, d=1;
	for(int i = 1; i <= n; i++){
		cin>>a; cin.get(); cin>>b;
		c = c*b+a*d;
		d *= b;
		int g = abs(gcd(c,d));
		c /= g;
		d /= g;
	}
	if(c==0){ cout<<"0\n"; return 0;}
	if(c<0){cout<<"-";c=-c;}
	if(c<d){printf("%d/%d",c,d);return 0;}
	if(c==d){cout<<"1";return 0;}
	if(c>d)cout<<(c/d);
	if(c%d!=0)printf(" %d/%d",c%d,d);
	return 0;
}

L1-010
#include<bits/stdc++.h>
using namespace std;
int a[5];
int main(){
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	cout<<a[1]<<"->"<<a[2]<<"->"<<a[3]<<endl;
	return 0;
}

L1-011
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a, b;
	getline(cin,a);
	getline(cin,b);
	for(int i = 0; i < a.size(); i++){
		if(b.find(a[i])!=string::npos)continue;
		cout<<a[i];
	}
	return 0;
}

L1-012
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;  cin>>n;
	printf("2^%lld = %lld\n",n,(1<<n));
	return 0;
}

L1-013
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;  cin>>n;
	int sum = 0;
	for(int i = 1; i <= n; i++){
		int t = 1;
		for(int j = 1; j <= i; j++){
			t *= j;
		}
		sum += t;
	}
	cout<<sum<<endl;
	return 0;
}

L1-014
#include<bits/stdc++.h>
using namespace std;
int main(){
	cout<<"This is a simple problem.";
	return 0;
}

L1-015
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;  cin>>n;
	int m = n*10/2;
	if(m%10>=5)m=m/10+1;
	else m = m/10;
	char ch;  cin>>ch;
	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= n; j++)
			putchar(ch);
		putchar('\n');
	}
	return 0;
}

L1-016
#include<bits/stdc++.h>
using namespace std;

int pows[] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
string m = "10X98765432";

int main(){
	int n;  cin>>n;
	int ok = 1;
	for(int i = 1; i <= n; i++){
		string s;  cin>>s;
		int z = 0;
		for(int j = 0; j < 17; j++)
			z += (s[j]-'0')*pows[j];
		z %= 11;
		if(s[17]!=m[z]){
			cout<<s<<endl;
			ok = 0;
		}
	}
	if(ok)cout<<"All passed\n";
	return 0;
}

L1-017
#include<bits/stdc++.h>
using namespace std;

int main(){
	string s;  cin>>s;
	
	double bt = 1;
	if(s[0]=='-'){bt *= 1.5; s=s.substr(1);}
	if(s[s.size()-1]%2==0)bt *= 2;
	
	int cnt = 0;
	for(int i = 0; i < s.size(); i++)
		if(s[i]=='2')cnt++;
	
	printf("%.2lf%\n",cnt*100.0/s.size()*bt);
	return 0;
}

L1-018
#include<bits/stdc++.h>
using namespace std;

int main(){
	int a, b; char ch;
	cin>>a>>ch>>b;
	if(a>=0 && a<12 || a==12&&b==0){
		printf("Only %02d:%02d.  Too early to Dang.",a,b);
		return 0;
	}
	int cc = a-12;
	if(b>0)cc++;
	for(int i = 1; i <= cc; i++)
		cout<<"Dang";
	return 0;
}

L1-019
#include<bits/stdc++.h>
using namespace std;

int main(){
	int A, B, n;
	cin>>A>>B>>n;
	int AA = A, BB = B;
	for(int i = 1; i <= n; i++){
		int a, b, c, d;
		cin>>a>>b>>c>>d;
		int cc = 0;
		if(b==a+c)cc++;
		if(d==a+c)cc--;
		if(cc>0)A--;
		if(cc<0)B--;
		if(A<0 || B<0)break;
	}
	if(A<0)cout<<"A\n"<<BB-B;
	else cout<<"B\n"<<AA-A;
	return 0;
}

L1-020
#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;  cin>>n;
	set<string>s;
	for(int i = 1; i <= n; i++){
		int k;  cin>>k;
		string st;
		if(k>=2){
			for(int j = 0; j < k; j++){
				cin>>st;  s.insert(st);
			}
		}else{
			cin>>st;
		}
	}
	int q;  cin>>q;
	set<string>repe; int ok = 0;
	for(int i = 1; i <= q; i++){
		string st;  cin>>st;
		if(s.find(st)==s.end() && repe.find(st)==repe.end()){
			repe.insert(st);
			if(ok)cout<<" ";
			cout<<st;
			ok = 1;
		}
	}
	if(!ok)cout<<"No one is handsome\n";
	return 0;
}

L1-021
#include<bits/stdc++.h>
using namespace std;

int main(){
	for(int i = 1; i <= 3; i++)
		printf("I'm gonna WIN!\n");
	
	return 0;
}


L1-022
#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;  cin>>n;
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		int x;  cin>>x;
		if(x%2==1)cnt++;
	}
	cout<<cnt<<" "<<n-cnt<<endl;
	return 0;
}


L1-023
#include<bits/stdc++.h>
using namespace std;
int a[110];
int main(){
	string s;  cin>>s;
	for(int i = 0; i < s.size(); i++){
		if(islower(s[i]))s[i] = s[i]-('a'-'A');
		a[s[i]-'A']++;
	}
	while(a['G'-'A'] || a['P'-'A'] || a['L'-'A'] || a['T'-'A']){
		if(a['G'-'A']){cout<<"G";a['G'-'A']--;}
		if(a['P'-'A']){cout<<"P";a['P'-'A']--;}
		if(a['L'-'A']){cout<<"L";a['L'-'A']--;}
		if(a['T'-'A']){cout<<"T";a['T'-'A']--;}
	}
	return 0;
}


L1-024
#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;  cin>>n;
	cout<<(n+1)%7+1;
	return 0;
}


L1-025
#include<bits/stdc++.h>
using namespace std;

int main(){
	string s;  getline(cin,s);
	string a = s.substr(0,s.find(' '));
	string b = s.substr(s.find(' ')+1);
	int aa=-1, bb=-1;
	int ok = 1;
	for(int i = 0; i < a.size(); i++)
		if(!isdigit(a[i]))ok = 0;
	if(ok && stoi(a)>=1 && stoi(a)<=1000)aa = stoi(a);
	ok = 1;
	for(int i = 0; i < b.size(); i++)
		if(!isdigit(b[i]))ok = 0;
	if(ok && stoi(b)>=1 && stoi(b)<=1000)bb = stoi(b);
	if(aa!=-1)cout<<aa;else cout<<"?";
	cout<<" + ";
	if(bb!=-1)cout<<bb;else cout<<"?";
	cout<<" = ";
	if(aa!=-1&&bb!=-1)cout<<aa+bb;
	else cout<<"?";
	return 0;
}


L1-026
#include<bits/stdc++.h>
using namespace std;

int main(){
	string s = "I Love GPLT";
	for(int i = 0; i < s.size(); i++){
		cout<<s[i]<<"\n";
	}
	return 0;
}


L1-027
#include<bits/stdc++.h>
using namespace std;

int a[11];
int main(){
	string s;  cin>>s;
	for(int i = 0; i < s.size(); i++)
		a[s[i]-'0']++;
	cout<<"int[] arr = new int[]{";
	int ok = 0; vector<int>vec;
	for(int i = 9; i >= 0; i--){
		if(a[i]){
			if(ok)cout<<",";
			cout<<i;
			ok = 1;
			vec.push_back(i);
		}
	}
	cout<<"};\n";
	cout<<"int[] index = new int[]{";
	for(int i = 0; i < s.size(); i++){
		if(i!=0)cout<<",";
		cout<<find(vec.begin(),vec.end(),s[i]-'0')-vec.begin();
	}
	cout<<"};\n";
	return 0;
}


L1-028
#include<bits/stdc++.h>
using namespace std;

int main(){
	int T;  cin>>T;
	while(T--){
		int n;  cin>>n;
		int prime = 1;
		if(n==1)prime = 0;
		for(int i = 2; i <= sqrt(n); i++){
			if(n%i==0){
				prime = 0;
				break;
			}
		}
		if(prime)cout<<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
}


L1-029
#include<bits/stdc++.h>
using namespace std;

int main(){
	int h;  cin>>h;
	printf("%.1f",(h-100)*0.9*2.0);
	return 0;
}


L1-030
#include<bits/stdc++.h>
using namespace std;
const int maxn = 55;
int main(){
	int n;  cin>>n;
	string nm[maxn]; int sex[maxn], vis[maxn];
	memset(vis,0,sizeof(vis));
	for(int i = 1; i <= n; i++){
		int x;  cin>>x;  sex[i] = x;
		string s;  cin>>s;  nm[i] = s;
	}
	for(int i = 1; i <= n; i++){
		if(!vis[i]){
			for(int j = n; j >= 1; j--){
				if(!vis[j] && sex[i]!=sex[j]){
					cout<<nm[i]<<" "<<nm[j]<<"\n";
					vis[i] = vis[j] = 1;
					break;
				}
			}
		}
	}
	return 0;
}


L1-031
#include<bits/stdc++.h>
using namespace std;
const int maxn = 55;
int main(){
	int T;  cin>>T;
	while(T--){
		double h, w; cin>>h>>w;
		double s = (h-100)*0.9*2.0;
		if(abs(s-w)<s*0.1){
			cout<<"You are wan mei!\n";
			continue;
		}
		if(w>s)
			cout<<"You are tai pang le!\n";
		else 
			cout<<"You are tai shou le!\n";
	}
	return 0;
}


L1-032
#include<bits/stdc++.h>
using namespace std;
const int maxn = 55;
int main(){
	int T;  cin>>T;
	while(T--){
		double h, w; cin>>h>>w;
		double s = (h-100)*0.9*2.0;
		if(abs(s-w)<s*0.1){
			cout<<"You are wan mei!\n";
			continue;
		}
		if(w>s)
			cout<<"You are tai pang le!\n";
		else 
			cout<<"You are tai shou le!\n";
	}
	return 0;
}


L1-033
#include<bits/stdc++.h>
using namespace std;
const int maxn = 55;
int main(){
	int x, n, y;
	cin>>x>>n;
	int xx = x;
	while(1){
		set<int>se;
		int t = x;
		for(int i = 0; i < 4; i++){
			se.insert(t%10);
			t /= 10;
		}
		if(se.size()==n){
			y = x;
			break;
		}
		x++;
	}
	printf("%d %04d",y-xx,y);
	return 0;
}

L1-034
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int a[maxn];
int main(){
	int n;  cin>>n;
	for(int i = 1; i <= n; i++){
		int k;  cin>>k;
		for(int j = 1; j <= k; j++){
			int x;  cin>>x;  a[x]++;
		}
	}
	int mx = -1e9, cc;
	for(int i = 0; i <= maxn; i++){
		if(a[i]>=mx){
			mx = a[i];
			cc = i;
		}
	}
	cout<<cc<<" "<<mx;
	return 0;
}


L1-035
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 3e5+10;

int main(){
	string a="", b="";
	for(int i = 1; i <= 14; i++){
		string x;  cin>>x;
		if(x==".")break;
		if(i==2)a = x;
		if(i==14)b = x;
	}
	if(a!=""&&b!="")
		cout<<a<<" and "<<b<<" are inviting you to dinner...\n";
	else if(a!=""&&b=="")
		cout<<a<<" is the only one for you...\n";
	else 
		cout<<"Momo... No one is for you ...\n";
	return 0;
}


L1-036
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 3e5+10;

int main(){
	int a, b;
	cin>>a>>b;
	cout<<a*b;
	return 0;
}


L1-037
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 3e5+10;

int main(){
	int a, b;  cin>>a>>b;
	if(b>0){
		printf("%d/%d=%.2f\n",a,b,a*1.0/b);
	}else if(b==0){
		printf("%d/0=Error\n",a);
	}else{
		printf("%d/(%d)=%.2f",a,b,a*1.0/b);
	}
	return 0;
}


L1-038
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 3e5+10;

int main(){
	cout<<"Hello World\n";
	cout<<"Hello New World\n";
	return 0;
}


L1-039
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 3e5+10;

int main(){
	int n;   cin>>n;  cin.get();
	string s;  getline(cin,s);
	//cout<<s<<endl;
	int x;
	if(s.size()%n==0)x = s.size()/n;
	else x = s.size()/n+1;
	string ans[1000];
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= x; j++){
			ans[i][j] = ' ';
		}
	}
	int cc = 0;
	for(int i = x; i >= 1; i--){
		for(int j = 1; j <= n; j++){
			if(cc>=s.size())break;
			ans[j][i] = s[cc++];
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= x; j++){
			cout<<ans[i][j];
		}
		cout<<"\n";
	}
	return 0;
}


L1-040
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 3e5+10;

int main(){
	int T;  cin>>T;
	while(T--){
		char a; double b;
		cin>>a>>b;
		//cout<<a<<" "<<b<<endl;
		if(a=='M')printf("%.2lf\n",b/1.09);
		else printf("%.2lf\n",b*1.09);
	}
	return 0;
}


L1-041
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
	int x, i; 
	for(i = 1; x!=250; i++)
		cin>>x;
	cout<<i-1;
	return 0;
}

L1-042
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c;
	scanf("%d-%d-%d",&a,&b,&c);
	printf("%04d-%02d-%02d\n",c,a,b);
	return 0;
}
L1-043
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1010;
struct node{int s=-1, t=-1, ti=0;}book[maxn];
int main(){
	int n;  cin>>n;
	for(int i = 1; i <= n; i++){
		int x; char op; int hh, mm;
		int ans = 0, cnt = 0;
		while(scanf("%d %c %d:%d",&x,&op,&hh,&mm) &&x){
			//cout<<x<<" "<<op<<" "<<hh<<" "<<mm<<"\n";
			if(op=='S'){
				book[x].s = hh*60+mm;
			}else if(book[x].s!=-1){
				book[x].t = hh*60+mm;
				ans += book[x].t-book[x].s;
				book[x].s = -1; //WA1,3又还了一次
				cnt++;
			}
		}
		if(ans!=0)printf("%d %d\n",cnt,(int)(ans*1.0/cnt+0.5));
		else printf("0 0\n");
	}
	return 0;
}

L1-044
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1010;
map<string, string>ma;
int main(){
	ma["ChuiZi"] = "Bu";
	ma["JianDao"] = "ChuiZi";
	ma["Bu"] = "JianDao";
	//freopen("input.txt","r",stdin);
	int k;  cin>>k;
	string s; int cnt = 0;
	while(cin>>s&&s!="End"){
		if(cnt==k){
			cout<<s<<"\n";
			cnt = 0;
		}else{
			cout<<ma[s]<<"\n";
			cnt++;
		}
	}
	return 0;
}

L1-045
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1010;
int main(){
	string s;  cin>>s;
	cout<<"Hello "<<s;
	return 0;
}

L1-046
//每次余数末位添1去运算,就不用写高精除法和取模了
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1010;
int main(){
	int x, s = 0, n = 0;
	cin>>x;
	while(s<x){s=s*10+1;n++;}
	while(1){
		cout<<s/x;
		s %= x;//被除数更新为余数
		if(s==0)break;
		s = s*10+1;//余数加1位
		n++;
	}
	cout<<" "<<n;
	return 0;
}

L1-047
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1010;
int main(){
	int n;  cin>>n;
	for(int i = 1; i <= n; i++){
		string nm;  int huxi, maibo;
		cin>>nm>>huxi>>maibo;
		if(huxi<15||huxi>20||maibo<50||maibo>70){
			cout<<nm<<"\n";
		}
	}
	return 0;
}

L1-048
//乘积C的第m行第n列的元素等于矩阵A的第m行的元素与矩阵B的第n列对应元素乘积之和
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1010;
int a[maxn][maxn], b[maxn][maxn];
int main(){
	int Ra, Ca, Rb, Cb;
	cin>>Ra>>Ca;
	for(int i = 1; i <= Ra; i++)
		for(int j =1; j <= Ca ;j++)
			cin>>a[i][j];
	cin>>Rb>>Cb;
	for(int i = 1; i <= Rb; i++)
		for(int j =1; j<=Cb; j++)
			cin>>b[i][j];
	if(Ca!=Rb)cout<<"Error: "<<Ca<<" != "<<Rb<<"\n";
	else{
		cout<<Ra<<" "<<Cb<<"\n";
		for(int i = 1; i <= Ra; i++){
			for(int j = 1; j <= Cb; j++){
				int sum = 0;
				for(int k = 1; k <= Ca; k++)
					sum += a[i][k]*b[k][j];
				if(j!=1)cout<<" ";
				cout<<sum;
			}
			cout<<"\n";
		}
	}
	return 0;
}

L1-049
#include<bits/stdc++.h>
using namespace std;
const int maxn = 110;
int n, m[maxn], seat[maxn*maxn];
vector<int>id[maxn];
int main(){
	cin>>n;
	for(int i = 1; i <= n; i++)
		cin>>m[i];
	int cnt = 1;
	while(1){
		int ok = 1;
		for(int i = 1; i <= n; i++){
			if(id[i].size()>=m[i]*10)continue;
			if(seat[cnt-1]!=i){
				seat[cnt] = i;
				id[i].push_back(cnt);
				cnt++;
			}else{
				seat[cnt+1] = i;
				id[i].push_back(cnt+1);
				cnt+=2;
			}
			ok = 0;
		}
		if(ok)break;
	}
	for(int i = 1; i <= n; i++){
		cout<<"#"<<i<<endl;
		for(int j = 0; j < id[i].size(); j++){
			if(j!=0 && j%10!=0)cout<<" ";
			if(j!=0 && j%10==0)cout<<"\n";
			cout<<id[i][j];
		}
		cout<<"\n";
	}
	return 0;
}



L1-050
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e6+10;

int main(){
	int L, n;  cin>>L>>n;
	n = pow(26,L)-n;
	//26进制转10进制
	vector<int>v;
	while(n){
		v.push_back(n%26);
		n /= 26;
	}
	//位数不够补0(a)
	for(int i = 0; i < L-v.size(); i++)
		cout<<'a';
	for(int i = v.size()-1; i >= 0; i--)
		cout<<(char)('a'+v[i]);
	return 0;
}



L1-051
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e6+10;

int main(){
	int n, x;
	cin>>n>>x;
	double ans = n*1.0*x/10.0;
	printf("%.2lf",ans);
	return 0;
}



L1-052
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e6+10;

int main(){
	cout<<"2018\nwo3 men2 yao4 ying2 !\n";
	return 0;
}



L1-053
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e6+10;

int main(){
	int a, b;
	cin>>a>>b;
	for(int i = 1; i <= a+b; i++)
		cout<<"Wang!";
	
	return 0;
}



L1-054
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e6+10;

int main(){
	int n; char ch;
	cin>>ch>>n;  cin.get();
	vector<string>v1,v2;
	for(int i = 1; i <= n; i++){
		string tmp;  getline(cin,tmp);
		v1.push_back(tmp);
		reverse(tmp.begin(),tmp.end());
		v2.push_back(tmp);
	}
	reverse(v2.begin(),v2.end());
	int ok = 1;
	for(int i = 0; i < v1.size(); i++)
		if(v1[i]!=v2[i])ok = 0;
	if(ok)cout<<"bu yong dao le\n";
	for(int i = 0; i < v2.size(); i++){
		for(int j = 0; j < v2[i].size(); j++){
			if(v2[i][j]=='@')cout<<ch;
			else cout<<" ";
		}
		cout<<"\n";
	}
	return 0;
}



L1-055
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e6+10;

int main(){
	int pa, pb, x1, x2, x3;
	cin>>pa>>pb>>x1>>x2>>x3;
	int a = x1+x2+x3, b = 3-a;
	if((pa>pb&&b>=1) || (pa<pb&&b==3)){
		cout<<"The winner is a: "<<pa<<" + "<<b<<"\n";
	}else{
		cout<<"The winner is b: "<<pb<<" + "<<a<<"\n";
	}
	return 0;
}



L1-056
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e6+10;
struct node{string name; int num; }a[maxn];
int main(){
	int n;  cin>>n;
	int sum = 0;
	for(int i = 1; i <= n; i++){
		cin>>a[i].name>>a[i].num;
		sum += a[i].num;
	}
	int avg = (sum/n)/2, mi = 1e9+10, t;
	for(int i = 1; i <= n; i++){
		if(abs(avg-a[i].num)<mi){
			mi = abs(avg-a[i].num);
			t = i;
		}
	}
	cout<<avg<<" "<<a[t].name<<"\n";
	return 0;
}



L1-057
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 3e5+10;

int main(){
	cout<<"PTA shi3 wo3 jing1 shen2 huan4 fa1 !\n";
	return 0;
}


L1-058
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 3e5+10;

int main(){
	string s;  getline(cin,s);
	for(int i = 0; i < s.size(); i++){
		if(s[i]!='6')cout<<s[i];
		else{
			int cc = i;
			while(s[cc]=='6' && cc<s.size())cc++;
			if(cc-i>9)cout<<"27";
			else if(cc-i>3)cout<<"9";
			else cout<<s.substr(i,cc-i);
			i = cc-1;
		}
	}
	return 0;
}


L1-059
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
	int n;  cin>>n;  cin.get();
	for(int i = 1; i <= n; i++){
		string s;  getline(cin,s);
		if(s.find("ong,")==string::npos||s.find("ong.")==string::npos){
			cout<<"Skipped\n";
			continue;
		}
		int d = s.find(','), ju = s.find('.');
		if(s.substr(d-3,3)!="ong" || s.substr(ju-3,3)!="ong")
			cout<<"Skipped\n";
		else{
			int jj = ju, cc = 0;
			while(cc<3 && jj>=0)if(s[jj--]==' ')cc++;
			cout<<s.substr(0,jj+1)<<" qiao ben zhong.\n";
		}
	}
	return 0;
}


L1-060
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x, y;  cin>>x>>y;
	printf("%d",100*100/2-100*(100-x)/2-100*y/2);
	return 0;
}


L1-061
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
	double x, y;
	cin>>x>>y;
	double z = x/y/y;
	printf("%.1lf\n",z);
	if(z>25.0){
		cout<<"PANG\n";
	}else{
		cout<<"Hai Xing\n";
	}
	return 0;
}


L1-062
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
	int n;  cin>>n;
	for(int i = 1; i <= n; i++){
		string s;  cin>>s;
		int a = 0, b = 0;
		for(int j = 0; j < 3; j++)a+=s[j]-'0';
		for(int j = 3; j < 6; j++)b+=s[j]-'0';
		if(a==b){
			cout<<"You are lucky!\n";
		}else{
			cout<<"Wish you good luck.\n";
		}
	}
	return 0;
}


L1-063
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
	int n;  cin>>n;
	for(int i = 1; i <= n; i++){
		int sx, hei, wei;
		cin>>sx>>hei>>wei;
		if(sx==1){
			if(hei==130)cout<<"wan mei! ";
			else if(hei<130)cout<<"duo chi yu! ";
			else cout<<"ni li hai! ";
			
			if(wei==27)cout<<"wan mei!\n";
			else if(wei<27)cout<<"duo chi rou!\n";
			else cout<<"shao chi rou!\n";
		}else{
			if(hei==129)cout<<"wan mei! ";
			else if(hei<129)cout<<"duo chi yu! ";
			else cout<<"ni li hai! ";
			
			if(wei==25)cout<<"wan mei!\n";
			else if(wei<25)cout<<"duo chi rou!\n";
			else cout<<"shao chi rou!\n";
		}
	}
	return 0;
}


L1-064
//大小写直接扫一遍处理。符号前面加空格当单词特判。空格用string流重新读一遍处理掉。
#include<bits/stdc++.h>
using namespace std;
int main(){
	//freopen("input.txt","w",stdout);
	int n=-1;  cin>>n;   cin.get();
	for(int i = 1; i <= n; i++){
		string s;  getline(cin,s);
		cout<<s<<endl<<"AI:";
		
		for(int j = 0; j < s.size(); j++){
			if(isalnum(s[j]) && s[j]!='I')
				s[j] = tolower(s[j]);
			else if(!isalnum(s[j]))//符号前面加空格分隔
				s.insert(j," "),j++;
			if(s[j]=='?')
				s[j] = '!';
		}
		
		string ans[1010];
		int cnt = 0;
		stringstream ss(s);
		while(ss>>s)ans[cnt++] = s;
		
		if(!isalnum(ans[0][0]))//RE or PE
			cout<<" ";
		for(int j = 0; j < cnt; j++){
			if(!isalnum(ans[j][0]))
				cout<<ans[j];//除了第一个,符号前不加空格
			else if(ans[j]=="can"&&ans[j+1]=="you"){
				cout<<" I can"; j++;
			}else if(ans[j]=="could"&&ans[j+1]=="you"){
				cout<<" I could"; j++;
			}else if(ans[j]=="I" || ans[j]=="me"){
				cout<<" you";
			}else {
				cout<<" "<<ans[j];
			}
		}
		cout<<"\n";
		
	}
	return 0;
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小哈里

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值