//水题,但是考点不水,可能用的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. Spark1.6 DataSets简介

    Apache Spark提供了强大的API,以便使开发者为使用复杂的分析成为了可能.通过引入SparkSQL,让开发者可以使用这些高级API接口来从事结构化数据的工作(例如数据库表,JSON文件),并 ...

  2. Spark on Yarn 架构解析

    . 一.Hadoop Yarn组件介绍: 我们都知道yarn重构根本的思想,是将原有的JobTracker的两个主要功能资源管理器 和 任务调度监控 分离成单独的组件.新的架构使用全局管理所有应用程序 ...

  3. cf380D Sereja and Cinema 组合数学

              time limit per test 1 second memory limit per test 256 megabytes input standard input outp ...

  4. weinre 手机端页面调试

    Weinre代表 Web Inspector Remote,是一种远程调试工具, 采用nodejs做为http服务器,用ajax通信 nodejs 官网 weinre官网 1.安装nodejs  会自 ...

  5. Js读写cookie实例

    统计访问次数 <html> <head> <meta http-equiv="Content-Type" content="text/htm ...

  6. JAVA 想让类无法new,可以使用private将类的构造函数改为私有的,这样new的时候就会报错了

    JAVA 想让类无法new,可以使用private将构造函数改为私有的,这样new的时候就会报错了 主要用于,静态工具类,静态类不需要new,直接使用   类名.静态方法  即可调用 class D{ ...

  7. 名词解释:DRAM, SRAM, SDRAM等

    SRAM:静态RAM,不用刷新,速度可以非常快,像CPU内部的cache,都是静态RAM,缺点是一个内存单元需要的晶体管数量多,因而价格昂贵,容量不大. DRAM:动态RAM,需要刷新,容量大. SD ...

  8. Jmeter监控服务器性能

    JMeter是一款压力测试工具,我们也可以用它来监控服务器资源使用情况.JMeter正常自带可以通过Tomcat的/manager/status来监控服务资源使用情况.这种情况只能监控Tomcat支持 ...

  9. printf("%*s\n", 1, ""); 使用"printf();" 的格式化输出动态制定等宽度输出。

    #include <stdio.h> #include <string.h> int main() { const char the_text[] = "this i ...

  10. Asp.Net 上传图片并生成高清晰缩略图(转)

    在asp.net中,上传图片功能或者是常用的,生成缩略图也是常用的.baidu或者google,c#的方法也是很多的,但是一用却发现缩略图不清晰啊,缩略图片太大之类的事情,下面是我在处理图片上的代码, ...