(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 ...
随机推荐
- AppBoxFuture: 服务模型的在线调试
框架内的服务模型(ServiceModel)用于处理各类业务逻辑(如最简单的CRUD操作),在设计时以类似于伪代码的形式存在,发布时后端会通过Roslyn转换并编译为运行时代码.为了方便开发者更简 ...
- 渗透测试-基于白名单执行payload--Compiler
复现亮神课程 0x01 Compiler前言 说明:Microsoft.Workflow.Comiler.exe是.NET Framework默认自带的一个实用工具,用户能够以XOML工作流文件的形式 ...
- ARM64架构下,OpenJDK的官方Docker镜像为何没有8版本
为什么需要ARM64架构的OpenJDK8的Docker镜像 对现有的Java应用,之前一直运行在x86处理器环境下,编译和运行都是JDK8,如今在树莓派的Docker环境运行(也可能是其他ARM环境 ...
- Win10系统Cortana 小娜无法搜索
1.在开始菜单中找“Windows PowerShell”文件夹,打开后右键单击Windows PowerShell,选择“以管理员身份运行” 2.输入命令,通过重新注册语音小娜来解决问题 Get-A ...
- Hello World ! 节日快乐!
节日快乐! 世界你好,Hello World Java public class HelloWorld{ public static void main(String[] args) { System ...
- [洛谷P2425]小红帽的回文数
原题传送门 这道题需要枚举.如果直接枚举会$TLE$. 考虑进制的转换:对于$> x$的进制下,一定是回文数 回文长度$2$位:设每一位为$i$,进制为$x$,则该数为$i*x+i$.反之,如果 ...
- 关于ESET占用CPU严重 的解决方案||ESET CPU 100%||用迅雷时ESET占用CPU(6月22日再次更新)
关于ESET占用CPU严重 的解决方案 本文根据原帖有适量删改. ESET 的杀毒软件历来以占用资源少,CPU消耗少著称,可是很多朋友(特别是中国大陆的朋友)反应ESS & EAV 间歇性占用 ...
- 5.分析snkrs的Android的DeviceID生产规则
分析Android的DeviceID生产 前面已经把web端的分析了一些,要想实现其实容易也难,容易是规则很容易,难是时间生成控制很难,我之前大概花了一周时间分析和梳理,然后行为测试,之前我已经讲过c ...
- LNMP与LAMP的工作原理
LAMP的实现原理 LAMP=Linux+Apache+Mysql+PHP.#工作原理:浏览器向服务器发送http请求,服务器 (Apache) 接受请求,由于php作为Apache的组件模块也会一 ...
- Python 中用面向对象的思想处理网页翻页 (初级)
第一种处理方法: class Pagenation(object): """ 处理分页相关的代码 """ def __init__(self ...