(Codeforce)Correct Solution?
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
−Shuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
−No problem! − said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
The first line contains one integer n (0≤n≤109) without leading zeroes. The second lines contains one integer m (0≤m≤109) − Bob's answer, possibly with leading zeroes.
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
3310
1033
OK
4
5
WRONG_ANSWER 简单来说就是输入一串数然后得到无前置0的最小数。
当然,输入这么大,肯定要数组来存
idea:0是肯定是最前面的。排序得到一串,然后判断是否有0,从第一个排好的数后,插入全部0就是最小了 判断第二行的数是不是最小的 AC:
感些algorithm库 竟然可以拍字符串
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
char a[], b[];
cin >> a >> b;
int len=strlen(a), n=, flag;
sort(a, a+len);
for(int i=;i<len;i++)
{
if(a[i]=='')
{
n++;
}
else
{
flag=a[i];
break;
}
}
a[]=flag;
if(n)
{
for(int i=;n--;i++)
{
a[i]='';
}
}
//cout << a;
if(strcmp(a, b)==)
cout << "OK";
else
cout << "WRONG_ANSWER";
return ;
}
(Codeforce)Correct Solution?的更多相关文章
- (Codeforce)The number of positions
Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say ...
- wf(五)
测试工作流: 运用wf(四)的solution: 创建单元测试项目: 1.选择HelloWorkflow解决方案,右键选择添加新建项目:选择单元测试模板,命名为HelloWorkflow.Tests. ...
- [LeetCode]题解(python):125 Valid Palindrome
题目来源 https://leetcode.com/problems/valid-palindrome/ Given a string, determine if it is a palindrome ...
- [LeetCode]题解(python):120 Triangle
题目来源 https://leetcode.com/problems/triangle/ Given a triangle, find the minimum path sum from top to ...
- [LeetCode]题解(python):119 Pascal's Triangle II
题目来源 https://leetcode.com/problems/pascals-triangle-ii/ Given an index k, return the kth row of the ...
- [LeetCode]题解(python):118 Pascal's Triangle
题目来源 https://leetcode.com/problems/pascals-triangle/ Given numRows, generate the first numRows of Pa ...
- wf(四)
我们已经在c#和xaml上编写了工作流,或者有的人会觉得在xaml上编写的workflow没什么优点,然而其实xaml其实具有一些很特别的优势. 1. xaml支持工作流设计器,c#不支持: 2. x ...
- wf(三)
前言: 到现在我们可以看到,WF4包含一个.xmal 文件的设计器和一个调用活动的runtime.当你创建自己的工作流的时候,你是同时也创建了一个活动, 因为活动是一个继承System.Activit ...
- [LeetCode]题解(python):093 Restore IP Addresses
题目来源 https://leetcode.com/problems/restore-ip-addresses/ Given a string containing only digits, rest ...
随机推荐
- Vue成员获取
0828自我总结 Vue成员获取 一.vue中data的获取 1.获取data里面的某个变量 $data.msg也可以简写成msg 2.获取data全部内容 $data 二.获取vue中vue挂钩的对 ...
- Vue中音乐播放器
一.安装依赖 yarn add vue-aplayer or` npm i vue-aplayer 二.使用 <template> <div class="vue_ap ...
- python selenium句柄操作
一.获取当前窗口句柄 1.元素有属性,浏览器的窗口其实也有属性的,只是你看不到,浏览器窗口的属性用句柄(handle)来识别. 2.人为操作的话,可以通过眼睛看,识别不同的窗口点击切换.但是脚本没长眼 ...
- cobalt strike批量发送钓鱼邮件
0×01 利用Cobalt strike生成木马 这里我们生成木马可以用cs带的HTA.OFFICE宏.word宏来使目标上线cs,这里以word宏病毒为例子. 首先我们需要制作一个word宏病毒来进 ...
- 关于用gulp合并压缩seaJs模块
现在很多人都在用seaJs来开发项目,seaJs上手容易,操作简单.但在后期做合并压缩的时候却中了个巨大无比的坑,但坑也总得有人来填.于是花了将近一个星期的时间来填了这坑,现将填坑的一些心得与大家分享 ...
- [专题练习] Part1 搜索
本文中的链接有的是题解有的是题目链接,已经搞混了... 一.DFS(深度优先搜索) 过于水略过. 二.BFS(广度优先搜索) 同上. 三.记忆化 记忆化搜索,就是我们的状态会重复利用,为了防止状态的重 ...
- 从C++到C++/CLI
本文转载于:https://www.cnblogs.com/feisky/archive/2009/11/22/1607999.html 刘未鹏(pongba) /文 看起来只是在C++后面多写了一个 ...
- AB实验的高端玩法系列2 - 更敏感的AB实验, CUPED!
背景 AB实验可谓是互联网公司进行产品迭代增加用户粘性的大杀器.但人们对AB实验的应用往往只停留在开实验算P值,然后let it go...let it go ... 让我们把AB实验的结果简单的拆解 ...
- 玩转OneNET物联网平台之HTTP服务③ —— OneNet智能灯 HTTP版本
授人以鱼不如授人以渔,目的不是为了教会你具体项目开发,而是学会学习的能力.希望大家分享给你周边需要的朋友或者同学,说不定大神成长之路有博哥的奠基石... QQ技术互动交流群:ESP8266&3 ...
- Kafka权威指南阅读笔记(第六章)
Broker配置 Kafka可以同时拥有可靠的主题和非可靠的主题.非可靠的主题允许丢失. 复制系数 主题级别的配置参数是 replication.factor,在Broker级别则可以通过defaul ...