(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 ...
随机推荐
- (图解)windows下自定义Eclipse主题
之前用过一些编辑器如SublimeText,IDE如phpstorm,IDEA等:这些工具给我的感觉就是,除了给予这些工具应有的功能外,给予开发者更友好,更舒服的界面.Eclipse很早就开始使用了, ...
- MySQL优化与实践
一.MySQL优化概括 二.SQL优化 实践: 1.查看是否开启了慢查询日志 show variables like 'slow_query_log' 没有开启 2.查看是否开启了未使用索引SQL记录 ...
- Java学习笔记之Object常用方法
Object:万类之祖 == : 比较的是是否是同一个对象,比较的是地址 equals: 是Object里面的方法,默认的是==,比较的是地址,但在String类型里重写为比较内容 一般我们在 ...
- 攻防世界(XCTF)WEB(进阶区)write up(一)
cat ics-05 ics-06 lottery Cat XCTF 4th-WHCTF-2017 输入域名 输入普通域名无果 输入127.0.0.1返回了ping码的结果 有可能是命令执行 ...
- Python之网络编程Socket
Python 提供了两个级别访问的网络服务.: 低级别的网络服务支持基本的 Socket,它提供了标准的 BSD Sockets API,可以访问底层操作系统Socket接口的全部方法. 高级别的网络 ...
- 设计糟糕的 RESTful API 就是在浪费时间!
现在微服务真是火的一塌糊涂.大街小巷,逢人必谈微服务,各路大神纷纷忙着把自家的单体服务拆解成多个Web微小服务.而作为微服务之间通信的桥梁,Web API的设计就显得非常重要. HTTP是目前互联网使 ...
- [NOIp2014] luogu P2312 解方程
题目描述 已知方程∑i=0naixi=0\sum_{i=0}^{n}{a_ix^i}=0i=0∑naixi=0求该方程在 [1,m][1,m][1,m] 内的整数解. Solution 有一个秦九 ...
- [LUOGU1437] 敲砖块
题目描述 在一个凹槽中放置了 n 层砖块.最上面的一层有n 块砖,从上到下每层依次减少一块砖.每块砖 都有一个分值,敲掉这块砖就能得到相应的分值,如下图所示. 14 15 4 3 23 33 33 7 ...
- Logstash 入门
一.简介 Logstash 是开源的服务器端数据处理管道,支持从不同来源采集数据,装换数据,并将数据发送到不同的存储库中. Logstash 项目诞生于 2009 年 8 月 2 日.其作者是世界著名 ...
- dos命令创建批处理脚本
win+r 打开cmd 输入 copy con 1.bat 回车 进入编辑状态输入 @echo off echo xxxx Ctrl+z 结束编辑 会在当前目录生成一个bat文件