//水题,但是考点不水,可能用的strlen属于string库,但是只能用于字符,不能用数字,因为\0就是0.出现0无法判断,其次二倍时有可能有进位

//第一次在二倍进位上出了问题

 #include<stdio.h>
#include<string.h>
int main()
{
//freopen("input.txt","r",stdin);
char s[];
int s1[];
int has[];
memset(has,,sizeof(has));
scanf("%s",s);
int i,len=strlen(s);
for(i=;i<len;i++) //hash
{
has[s[i]-'']++;
}
int c=,len1=;
for(i=len-;i>=;i--) //计算2倍
{
int m=c+(s[i]-'')*;
has[m%]--; //hash 比较
s1[len1++]=m%;
c=m/;
}
if(c!=)s1[len1++]=c;
if(len1!=len)printf("No\n"); //进位
else{
for(i=;i<;i++)
if(has[i]!=)break; //出现次数不一样
if(i<)printf("No\n");
else printf("Yes\n");
}
for(i=len1-;i>=;i--) //不论yes or no 输出
printf("%d",s1[i]);
printf("\n");
}

PAT1023. Have Fun with Numbers的更多相关文章

  1. PAT1023. Have Fun with Numbers (20)

    #include <iostream> #include <map> #include <algorithm> using namespace std; strin ...

  2. Java 位运算2-LeetCode 201 Bitwise AND of Numbers Range

    在Java位运算总结-leetcode题目博文中总结了Java提供的按位运算操作符,今天又碰到LeetCode中一道按位操作的题目 Given a range [m, n] where 0 <= ...

  3. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  4. [LeetCode] Add Two Numbers II 两个数字相加之二

    You are given two linked lists representing two non-negative numbers. The most significant digit com ...

  5. [LeetCode] Maximum XOR of Two Numbers in an Array 数组中异或值最大的两个数字

    Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. Find the maximum re ...

  6. [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  7. [LeetCode] Bitwise AND of Numbers Range 数字范围位相与

    Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers ...

  8. [LeetCode] Valid Phone Numbers 验证电话号码

    Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bas ...

  9. [LeetCode] Consecutive Numbers 连续的数字

    Write a SQL query to find all numbers that appear at least three times consecutively. +----+-----+ | ...

随机推荐

  1. 输出一个对象的所有属性的值,可以不用反射机制,用JSON处理更方便

    String r = ""; ObjectMapper mapper = new ObjectMapper(); r = mapper.writeValueAsString(cre ...

  2. hdu 5441 travel 离线+带权并查集

    Time Limit: 1500/1000 MS (Java/Others)  Memory Limit: 131072/131072 K (Java/Others) Problem Descript ...

  3. vs2012出现无法启动iis express web 服务器的错误

    一直用的好好的,今天调试时却总报上面的错误.“文件查看器”->"windows 日志"->"系统"里发现有几条“HttpEvent”错误, 具体信息 ...

  4. Linux查看程序端口占用情况(转载)

    From:http://www.cnblogs.com/benio/archive/2010/09/15/1826728.html 今天发现服务器上Tomcat 8080端口起不来,老提示端口已经被占 ...

  5. Log4Net在Windows服务中不能记录日志 z

    解决方案: 在Windows安装服务的“serviceProcessInstaller1”中修改Account属性为LocalSystem.见下图 后来查了一下这个Account属性 说白了还是权限的 ...

  6. Perl模块的安装方法

    1. 下载离线安装包 *.tar.gz的形式解包后,#perl Makefile.PL#make#make install 2. 在联网的情况下,通过CPAN安装# perl -MCPAN -e sh ...

  7. [ActionScript3.0] 传递任意数量的参数

    function setAgument(a:int,...rest):void{ for(var i:int=0;i<rest.length;i++){ trace(rest[i]); }}se ...

  8. bat操作数据库mysql

    createDB.bat文件内容: @echo off cd C:/Program Files/cl_ZWL_App/<a href="http://lib.csdn.net/base ...

  9. SQLAlchemy指南(tutorial)

    对应版本: 0.3.4 目录 1 安装 1.1 安装SQLAlchemy 1.2 安装一个数据库API 2 快速开始 2.1 导入 2.2 连接到数据库 3 SQLAlchemy是两个库的包装 4 操 ...

  10. 如何在组件(Component中)模拟用户控件(UserControl)中FindForm()?

    using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentM ...