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. day4-hdfs的核心工作原理\写数据流程 \读数据流程

    namenode元数据管理要点 1.什么是元数据? hdfs的目录结构及每一个文件的块信息(块的id,块的副本数量,块的存放位置<datanode>) 2.元数据由谁负责管理? namen ...

  2. matlab Newton method

    % Matlab script to illustrate Newton's method % to solve a nonlinear equation % this particular scri ...

  3. android中单元測试中的断言assert的使用与扩展

    首先看一组对照,比方说我们要測试的结果是一个Linearlaout AssertJ Android: assertThat(layout).isVisible() .isVertical() .has ...

  4. 简单区分iphone和ipad的宏定义

    在公共头文件里作例如以下定义: #define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 使用时: if( IS_I ...

  5. PHP连接数据库(注冊页面的增删改查)

    1.连接数据库 ---------–connect.php--------------– <?php //本地測试 $host = '127.0.0.1'; $port = 3306; $use ...

  6. location.replace

    [root@bigdata-server-01 ~]# curl www.baidu.com<!DOCTYPE html><!--STATUS OK--><html> ...

  7. ios33--线程安全

    // // ViewController.m // 05-掌握-线程安全 // // 多线程下载文件:每个线程下的部分可能是交错的,到时候就拼接不了.除非每个线程下载的不是交错的,而是从头到尾依次分开 ...

  8. Codeforces Round #498 (Div. 3) 简要题解

    [比赛链接] https://codeforces.com/contest/1006 [题解] Problem A. Adjacent Replacements        [算法] 将序列中的所有 ...

  9. bzoj1597 [Usaco2008 Mar]土地购买——斜率优化DP

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1597 就是斜率优化水题... 然而WA了十几遍,正负号处理真让人心累... 还是该负就负,别 ...

  10. java笔记线程方式1线程暂停yield

    public static void yield():暂停当前正在执行的线程对象,并执行其他线程. 让多个线程的执行更和谐,但是不能靠它保证一人一次. public class ThreadYield ...