(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 ...
随机推荐
- 从源码角度看JedisPoolConfig参数配置
做一个积极的人 编码.改bug.提升自己 我有一个乐园,面向编程,春暖花开! 你好,JedisPoolConfig Java中使用Jedis作为连接Redis的工具.在使用Jedis的也可以配置Jed ...
- 快速入门Maven(一)
一.Maven简介 1.什么是maven Apache组织中的一个颇为成功的开源项目,Maven主要服务于基于Java平台的项目构建.依赖管理和项目信息管理. 2.Maven的好处 构建是程序员每天要 ...
- python selenium自动化常用关键字
工具安装: 1.安装python 2.安装selenium库(dos命令下进入selenium-2.53.2存放路径,执行pip install selenium-2.53.2) 3.将浏览器驱动放到 ...
- 阻塞IO模型
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<unistd.h> # ...
- Kubernetes WebSSH终端窗口自适应Resize
追求完美不服输的我,一直在与各种问题斗争的路上痛并快乐着 上一篇文章Django实现WebSSH操作Kubernetes Pod最后留了个问题没有解决,那就是terminal内容窗口的大小没有办法调整 ...
- Vulnhub靶场渗透练习(三) bulldog
拿到靶场后先对ip进行扫描 获取ip 和端口 针对项目路径爆破 获取两个有用文件 http://192.168.18.144/dev/ dev,admin 更具dev 发现他们用到框架和语言 找到一 ...
- Spring MVC(1)Spring MVC的初始化和流程以及SSM的实现
一.Spring MVC概述 1.Spring MVC 的架构 对于持久层而言,随着软件的发展,迁移数据库的可能性很小,所以在大部分情况下都用不到Hibernate的HQL来满足迁移数据库的要求.与此 ...
- style.html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 数据库系统(六)---MySQL语句及存储过程
一.DDL.DML.DCL常用语句 1.DDL(Data Definition Language)数据库定义语言 (1)数据库模式定义 #创建数据库 create database if exsite ...
- MarkDown的常用语法
个人比较喜欢Markdown的语法,常用来做一些笔记,下面就简单介绍一下它的语法. 概览 宗旨 Markdown 的目标是实现「易读易写」. 可读性,无论如何,都是最重要的.一份使用 Markdown ...