当前位置:网站首页>A section of school recruitment and test questions 1-a-share online innovation
A section of school recruitment and test questions 1-a-share online innovation
2022-04-22 00:13:00 【Greedy grapes】
A section of the school entrance examination questions 1-A Play new on the stock line
【 Input 】
Enter the assignment start number in the first line num, Number of allotments x.
In the next few lines, enter n Hemo n digit , Space between .
Input END end .
Such as :
12345 5
2 12 23
3 123 345
END
【 Output 】
Judge whether the lot is won . At the end of the n The number of digits and the end of the new number n If the digits match, the lot will be won , Output YES, Then output the winning numbers in turn . Otherwise output NO.
Such as :
YES
345
【 notes 】
Call a new number {num,num+1,…,num+x-1}.
#include <bits/stdc++.h>
using namespace std;
// Split string
vector<string> splitSpace(string& str, char ch)
{
vector<string> ans;
string ansstr;
for (int i = 0; i < str.size(); i++)
{
if (str[i] == ch)
{
if (!ansstr.empty())
{
ans.push_back(ansstr);
ansstr.clear();
}
continue;
}
if (i == str.size() - 1 && isdigit(str[i]))
{
ansstr += str[i];
ans.push_back(ansstr);
break;
}
ansstr += str[i];
}
return ans;
}
// String to integer
int str2int(string& str)
{
int ans = 0, slope = 1;
for (int i = str.size() - 1; i >= 0; i--)
{
ans += (str[i] - '0') * slope;
slope *= 10;
}
return ans;
}
// String addition
string stradd(string& str1, string& str2)
{
string ans;
int cur = 0, i = str1.size() - 1, j = str2.size() - 1;
while (i >= 0 || j >= 0 || cur != 0)
{
if (i >= 0)
cur += str1[i--] - '0';
if (j >= 0)
cur += str2[j--] - '0';
if (cur % 10 >= 0)
ans += to_string(cur % 10);
cur /= 10;
}
reverse(ans.begin(), ans.end());
return ans;
}
int main()
{
string input;
getline(cin, input);
vector<string> numX = splitSpace(input, ' ');
string num = numX[0];
int x = str2int(numX[1]);
vector<string> ans;
do
{
input.clear();
getline(cin, input);
if (input == string("END"))
{
break;
}
vector<string> array = splitSpace(input, ' ');
int tail = str2int(array[0]);
for (int i = 1; i < array.size(); i++)
{
string match = num;
for (int k = 0; k < x; k++)
{
string sk = to_string(k);
match = stradd(num, sk);
string subs = match.substr(match.size() - tail, match.size() - 1);
if (subs == array[i])
{
ans.push_back(array[i]);
}
}
}
} while (true);
if (ans.empty())
{
cout << "NO" << endl;
}
else
{
cout << "YES" << endl;
for (auto &&e : ans)
{
cout << e << " ";
}
cout << endl;
}
return 0;
}
版权声明
本文为[Greedy grapes]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220007574505.html
边栏推荐
- Fansea 4W single coil transmitting wireless charging 5W module
- 刷题整理(一)
- Function of freewheeling diode in switching power supply
- Low cost Wireless SoC chip for fs68001a and fs68003
- 笔记本拓展外接显示器时 鼠标移动不到主显示器外的另一块屏上
- AI助力劳保防护装备穿戴监测,为企业安全生产保驾护航
- GDB debug application record
- Why should relays be connected in parallel with diodes
- Blender mmd 导出FBX模型 和 烘焙动画
- 一文读懂MES系统生产调度管理功能
猜你喜欢
随机推荐
2022 Quality Officer - decoration direction - post skills (Quality Officer) test simulation 100 questions simulation test platform operation
刷题整理(一)
内存管理、
Deep learning (15): instructions for kitti2bag
Deeptech released seven trends of advanced computing in 2022, breaking the shackles of Moore and winning the era of computing power
都说MES能提高企业生产效率,具体表现在哪些方面呢?
小程序 分包
Low cost Wireless SoC chip for fs68001a and fs68003
Browser principle learning notes 1 - browser process
dp 优化
一文读懂MES系统生产调度管理功能
Kubernetes deployment: offline deployment of highly available kubernetes clusters using kubespreay (scheme 1)
等待wait(),wait(long),wait(long,int)/通知机制notify(),notifyAll()
What kind of sports headphones should you choose and what style of headphones are comfortable to wear
架构实战营-模块三-作业
Redis source code linked list (adlist. H and adlist. C) (Part 1)
找出和为指定值的下标对-c语言暴力解法
L1-059 敲笨钟
09. 树莓派ASP.NET环境配置
2022 China eye Expo, Beijing Youth eye health industry exhibition, eye care education equipment exhibition








![[SCTF2019]Flag Shop erb模板注入](/img/d7/ff19478a39bd2d189cfc4c8fe8763f.png)