当前位置:网站首页>L1-075 强迫症 (10 分)
L1-075 强迫症 (10 分)
2022-04-22 23:53:00 【NEFU AB-IN】
Powered by:NEFU AB-IN
文章目录
L1-075 强迫症 (10 分)
-
题意
小强在统计一个小区里居民的出生年月,但是发现大家填写的生日格式不统一,例如有的人写 199808,有的人只写 9808。有强迫症的小强请你写个程序,把所有人的出生年月都整理成 年年年年-月月 格式。对于那些只写了年份后两位的信息,我们默认小于 22 都是 20 开头的,其他都是 19 开头的。
-
思路
补充C++ string的相关函数
stoll将string转化为long longto_string()将任意类型转化为stringstrstr(s1, s2)kmp的复杂度,找到s2在s1中的第一个下标string.c_str()可以理解为string转化为char数组输出,这样就可以%s输出了
-
代码
/* * @Author: NEFU AB-IN * @Date: 2022-04-22 16:45:11 * @FilePath: \ACM\GPLT\L1-075.CPP * @LastEditTime: 2022-04-22 16:56:30 */ #include <bits/stdc++.h> using namespace std; #define int long long #define MP make_pair #define SZ(X) ((int)(X).size()) #define IOS \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define DEBUG(X) cout << #X << ": " << X << endl; typedef pair<int, int> PII; const int INF = 0x3f3f3f3f; signed main() { IOS; string s, year, month; cin >> s; if (SZ(s) == 6) { year = s.substr(0, 4); month = s.substr(4, 2); printf("%s-%s", year.c_str(), month.c_str()); } else { year = s.substr(0, 2); month = s.substr(2, 2); int y = stoll(year); if (y < 22) printf("20%s-%s", year.c_str(), month.c_str()); else printf("19%s-%s", year.c_str(), month.c_str()); } return 0; }
版权声明
本文为[NEFU AB-IN]所创,转载请带上原文链接,感谢
https://ab-in.blog.csdn.net/article/details/124350449
边栏推荐
- Redis的基本使用
- "New programmer 003" was officially launched, and the cloud native and digital combat experience of 30 + companies such as Huawei and Alibaba
- OpenCv入门(二)——仿射变换和透视变换
- visual studio 总是和搜狗输入法冲突
- [perseverance challenge] PCIe daily question and answer (table of contents)
- 云计算仿真框架CloudSim介绍(截图版)
- 两种颜色渐变
- 2022 hard plus deshmann annual summit: release of a variety of pilot flagship to lead the high-end market
- ssh: connect to host 172.31.8.132 port 22: Connection refused
- 字符集合(去重)
猜你喜欢

Django creates table structure and adds, deletes, modifies and queries database

matlab-day01
![FileNotFoundError: [Errno 2] No such file or directory: 'image/1. Jpg 'problem solving](/img/dd/d8068792911be2d04a04eb4c1a158c.png)
FileNotFoundError: [Errno 2] No such file or directory: 'image/1. Jpg 'problem solving
![[perseverance challenge] PCIe asks and answers every day (filed on March 2022)](/img/3c/b23b90c92a82922a710623b1142412.png)
[perseverance challenge] PCIe asks and answers every day (filed on March 2022)

LabVIEW控制电脑关机、休眠、注销和重启

MySQL索引的语法是什么
![[turtle confession collection]](/img/97/6f1008386931bcb93655d94121e2c4.png)
[turtle confession collection] "the moon at the bottom of the sea is the moon in the sky, and the person in front of us is the sweetheart." More joy and peace for the rest of your life ~ (with 3 sourc

Django创建表结构及对数据库增删改查

No module named 'Django is reported when Django specifies the database_ test. settings‘

Reg regular expression learning notes
随机推荐
FileNotFoundError: [Errno 2] No such file or directory: 'image/1. Jpg 'problem solving
【Turtle表白合集】“海底月是天上月,眼前人是心上人。”余生多喜乐,长平安~(附3款源码)
FPGA (VI) RTL code II (complex circuit design 1)
stm32f103 独立看门狗
Fundamentals of programming language (1)
Share two recent classic OJ questions (arrange subsequences + find the longest continuous number string in the string)
FPGA (V) one of RTL codes (cross clock domain design)
(MM-2018)用于行人重识别的局部卷积神经网络
80386 compilation_ Introduction to global description table GDT
SystemVerilog verification - Test Platform preparation guide learning notes (1): data types
[annual summary] carry forward the past and forge ahead into the future: look back on the unreliable 2021 and hope for the reliable 2022
[PCIe 6.0] new features of PCIe 6.0 - detailed explanation of dmwr (deferred memory write)
80386汇编_全局描述表GDT介绍
51 single chip microcomputer learning_ 4-2 nixie tube dynamic display
FileNotFoundError: [Errno 2] No such file or directory: 'image/1.jpg'问题解决
2022硬刚PLUS德施曼年度峰会:多款领航旗舰发布,引领高端市场
Traceup | a powerful tool to reduce stress and achieve more success and help you get rid of work anxiety
websoket封装版 参数配置化 开箱即用
【Pygame小游戏】Chrome上的小恐龙竟可以用代码玩儿了?它看起来很好玩儿的样子~
Interpretation of UVM source code, uvm-1.2 code review notes