Question:http://poj.org/problem?id=1016
问题点:水题。
 Memory: 232K        Time: 125MS
Language: C++ Result: Accepted #include <iostream>
#include <string>
using namespace std; string inventory(string n)
{
int i;
int t[];
char ch[];
memset(t,,sizeof(t));
for(i=;i<n.length();i++)
{
t[n.at(i)-'']++;
}
n.clear();
for(i=;i<;i++)
{
if(t[i]==) continue;
sprintf_s(ch,"%d%d",t[i],i);
n+=ch;
}
return n;
}
int main()
{
int i,j;
bool flag;
string n[];
while(cin>>n[] && n[]!="-1")
{
flag = false;
for(i=;i<;i++)
{
n[i] = inventory(n[i-]);
for(j=;j<i;j++)
{
if(n[i]==n[j])
{
flag = true;
if(i==)
{
cout<<n[]<<" is self-inventorying"<<endl;
}
else if((i-j)==)
{
cout<<n[]<<" is self-inventorying after "<<j<<" steps"<<endl;
}
else
{
cout<<n[]<<" enters an inventory loop of length "<<i-j<<endl;
}
}
}
if(flag) break;
}
if(!flag) cout<<n[]<<" can not be classified after 15 iterations"<<endl;
}
return ;
}

北大ACM(POJ1016-Numbers That Count)的更多相关文章

  1. POJ1016 Numbers That Count

    题目来源:http://poj.org/problem?id=1016 题目大意: 对一个非负整数定义一种运算(inventory):数这个数中各个数字出现的次数,然后按顺序记录下来.比如“55531 ...

  2. 北大 ACM 分类 汇总

    1.搜索 //回溯 2.DP(动态规划) 3.贪心 北大ACM题分类2009-01-27 1 4.图论 //Dijkstra.最小生成树.网络流 5.数论 //解模线性方程 6.计算几何 //凸壳.同 ...

  3. 北大ACM - POJ试题分类(转自EXP)

    北大ACM - POJ试题分类 -- By EXP 2017-12-03 转载请注明出处: by EXP http://exp-blog.com/2018/06/28/pid-38/ 相关推荐文: 旧 ...

  4. poj 1016 Numbers That Count

    点击打开链接 Numbers That Count Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 17922   Accep ...

  5. 北大ACM题库习题分类与简介(转载)

    在百度文库上找到的,不知是哪位大牛整理的,真的很不错! zz题 目分类 Posted by fishhead at 2007-01-13 12:44:58.0 -------------------- ...

  6. ACM: FZU 2105 Digits Count - 位运算的线段树【黑科技福利】

     FZU 2105  Digits Count Time Limit:10000MS     Memory Limit:262144KB     64bit IO Format:%I64d & ...

  7. 北大ACM(POJ1009-Edge Detection)

    Question:http://poj.org/problem?id=1009问题点:RLE编码. Memory: 648K Time: 547MS Language: C++ Result: Acc ...

  8. 北大ACM(POJ1753-Flip Game)

    Question:http://poj.org/problem?id=1753 问题点:穷举. #include <iostream> using namespace std; ][];/ ...

  9. B - Numbers That Count

    Description        "Kronecker's Knumbers" is a little company that manufactures plastic di ...

随机推荐

  1. Hadoop 执行过程中出现 name node is in safe mode 问题

    解决方法: 1.进入hadoop安装根目录 如 :我的hadoop 安装在/usr/local/hadoop 执行 cd /usr/local/hadoop bin/hadoop dfsadmin - ...

  2. CodeForces484A Bits(贪心)

    CodeForces484A Bits(贪心) CodeForces484A 题目大意:给出范围[A.B].期望你给出某个数X满足X属于[A,B],而且X转成二进制的1的个数最多.假设有多个给出最小的 ...

  3. react 项目实战(九)登录与身份认证

    SPA的鉴权方式和传统的web应用不同:由于页面的渲染不再依赖服务端,与服务端的交互都通过接口来完成,而REASTful风格的接口提倡无状态(state less),通常不使用cookie和sessi ...

  4. Android解析程序包时出现问题

    Android用户下载我们wcc应用时,偶尔会出现“解析程序包出现问题”的的现象,以下是逐步排查的相关经验: 1. 首先确保这个包本身没有问题. 检测方法:其他手机采用同样的下载方式再下载一次. 解决 ...

  5. linux文件系统的权限简单介绍

    linux系统下,文件的权限是这样表示的: - --- --- --- 一共用10位的二进制进行表示,其中 位置 0 :  - :文件        d :目录剩下的9个位置:位置1-3 当前用户(应 ...

  6. java7新特性之Diamond syntax

    java7新特性之Diamond syntax Java 7 also introduces a change that means less typing for you when dealing ...

  7. Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '=

    [SQL]SELECT username,password,toutiao_uidFROM pwdtab pLEFT JOIN toutiao_action_article aON p.toutiao ...

  8. [Unity-21] Prefab具体解释

    1.什么是Prefab? Prefab又被称为预设,以下部分来自官网:预置是一种资源类型--存储在项目视图中的一种可反复使用的游戏对象.预置能够多次放入到多个场景中. 当你加入一个预置到场景中,就创建 ...

  9. leetcode 690. Employee Importance——本质上就是tree的DFS和BFS

    You are given a data structure of employee information, which includes the employee's unique id, his ...

  10. Notification操作大全

    目录 一:普通的Notification Notification 的基本操作 给 Notification 设置 Action 更新 Notification 取消 Notification 设置 ...