蓝桥杯[第四届][B组]-错误票据
2022-04-04 22:29 幻霞 阅读(26) 评论(0) 编辑 收藏 举报
第四届的题,思路不难,但是输入方式比较奇特,字符串和输入输出基础不好会耗费较多的时间,代码这里把快读改了一下,熟悉的朋友应该能很快改回来。
#include <bits/stdc++.h> using namespace std; int f[100005]= {0}; char s[100005]={0}; int p=0,in,line,c,i; inline int read() { register bool b=0; register char ch=s[p++]; register int x=0; while((ch<'0' || ch>'9') && ch!='-') ch=s[p++]; (ch=='-') && (b=1,ch=s[p++]); while(ch>='0' && ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=s[p++]; return b?-x:x; } int main() { cin>>line; getchar(); while(line--) { gets(s); while(p<strlen(s)) { in=read(); if((++f[in])==2) c=in; } p=0; } while(f[i]==0)i++; while(f[i]) i++; cout<<i<<" "<<c; return 0; }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架