Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:注意点:1.过滤Q和Z,2.注意输出格式

Posted by RJZQH at 2022-04-08 16:33:24 on Problem 1002
In Reply To:注意点:1.过滤Q和Z,2.注意输出格式 Posted by:zlf1215 at 2020-08-18 15:39:28
> 1.“Q”和“Z”要和“-”一起过滤掉,不然会WA
> 2.注意输出格式,printf("%03d-%04d %d",)
> 另附自己垃圾代码
> #include<cstdio>
> #include<cstring>
> #include<map>
> #include<queue>
> #include<algorithm>
> using namespace std;
> 
> int main()
> {
> 	int N,n;
> 	scanf("%d",&N);
> 	n=N;
> 	char str[100];
> 	map<int, int> m;	
> 	priority_queue<int,vector<int>, greater<int> > q;
> 	for(int i=0;i<n;i++)
> 	{
> 		scanf("%s",str);
> 		int bz=0,t;
> 		for(int j=0;j<strlen(str);j++)
> 		{
> 			if(str[j]=='-'||str[j]=='Q'||str[j]=='Z')
> 				continue;
> 			else 
> 			{
> 				if(str[j]>='0'&&str[j]<='9')
> 				{
> 					t=str[j]-'0';
> 				}
> 				else
> 					switch(str[j])
> 					{
> 						case 'A':
> 						case 'B':
> 						case 'C': t=2;break;
> 						case 'D':
> 						case 'E':
> 						case 'F': t=3;break;
> 						case 'G':
> 						case 'H':
> 						case 'I': t=4;break;
> 						case 'J': 
> 						case 'K':
> 						case 'L': t=5;break;
> 						case 'M':
> 						case 'N':
> 						case 'O': t=6;break;
> 						case 'P':
> 						case 'R':
> 						case 'S': t=7;break;
> 						case 'T':
> 						case 'U':
> 						case 'V': t=8;break;
> 						case 'W':
> 						case 'X':
> 						case 'Y': t=9;break;
> 						default: break;		
> 					}
> 			}
> 			
> 			bz=bz*10+t;					
> 		}
> 		if(m[bz]++==0)	q.push(bz);	
> 	}
> 
> 	int flag=1;
> 	while(!q.empty())
> 	{
> 		if(m[q.top()]!=1)
> 		{
> 			printf("%03d-%04d %d\n",q.top()/10000,q.top()%10000,m[q.top()]);
> 			flag=0;
> 		}	
> 		q.pop();
> 	}
> 	if(flag)	puts("No duplicates.\n");
> 	
> 	return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator