北大ACM(POJ1016-Numbers That Count)
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)的更多相关文章
- POJ1016 Numbers That Count
题目来源:http://poj.org/problem?id=1016 题目大意: 对一个非负整数定义一种运算(inventory):数这个数中各个数字出现的次数,然后按顺序记录下来.比如“55531 ...
- 北大 ACM 分类 汇总
1.搜索 //回溯 2.DP(动态规划) 3.贪心 北大ACM题分类2009-01-27 1 4.图论 //Dijkstra.最小生成树.网络流 5.数论 //解模线性方程 6.计算几何 //凸壳.同 ...
- 北大ACM - POJ试题分类(转自EXP)
北大ACM - POJ试题分类 -- By EXP 2017-12-03 转载请注明出处: by EXP http://exp-blog.com/2018/06/28/pid-38/ 相关推荐文: 旧 ...
- poj 1016 Numbers That Count
点击打开链接 Numbers That Count Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 17922 Accep ...
- 北大ACM题库习题分类与简介(转载)
在百度文库上找到的,不知是哪位大牛整理的,真的很不错! zz题 目分类 Posted by fishhead at 2007-01-13 12:44:58.0 -------------------- ...
- ACM: FZU 2105 Digits Count - 位运算的线段树【黑科技福利】
FZU 2105 Digits Count Time Limit:10000MS Memory Limit:262144KB 64bit IO Format:%I64d & ...
- 北大ACM(POJ1009-Edge Detection)
Question:http://poj.org/problem?id=1009问题点:RLE编码. Memory: 648K Time: 547MS Language: C++ Result: Acc ...
- 北大ACM(POJ1753-Flip Game)
Question:http://poj.org/problem?id=1753 问题点:穷举. #include <iostream> using namespace std; ][];/ ...
- B - Numbers That Count
Description "Kronecker's Knumbers" is a little company that manufactures plastic di ...
随机推荐
- C#的DataGridView如何修改字体
在RowTemplate中可以修改字体和显示的格式(比如保留几位小数)
- Tcl学习之--文件操作
Tcl中文件名称操作遵循Unix/Linux的命名规范. x/y/z表示x文件夹下的y 子文件夹及y以下的子文件夹z. ~admin/email则表示admin用户的email目录. l file ...
- Struts2.3动态调用报 No result defined for action 错误
struts 2.3.16 採用动态调用发现不工作报404 not found,网上查找原因: 1.由于:struts2中默认不同意使用DMI 所以:须要在配置文件里打开: <constant ...
- Kafka跨集群同步工具——MirrorMaker
MirrorMaker是为解决Kafka跨集群同步.创建镜像集群而存在的.下图展示了其工作原理.该工具消费源集群消息然后将数据又一次推送到目标集群. watermark/2/text/aHR0cDov ...
- css的white-space属性导致了空格问题——查看十六进制发现2020变成了c2a0
今天发现了一个奇怪的问题.从文本编辑器(notepad++)中把一段文本输入到easyui的textbox文本框(textarea)中,不进行不论什么的操作.直接再从文本框中把文本拷贝出来贴到文本编译 ...
- Python学习笔记17:标准库之数学相关(math包,random包)
前面几节看得真心累.如今先来点简单easy理解的内容. 一 math包 math包主要处理数学相关的运算. 常数 math.e # 自然常数e math.pi # 圆周率pi 运算函数 math ...
- 图像处理之基础---彩色转灰度算法优化rgb to yuv
File: StudyRGB2Gray.txtName: 彩色转灰度算法彻底学习Author: zyl910Version: V1.0Updata: 2006-5- ...
- lua-5.2.3编译问题记录"libreadline.so: undefined reference to `PC'"
作者:zhanhailiang 日期:2014-10-21 [root@~/software]# cd lua-5.2.3 [root@~/software/lua-5.2.3]# make linu ...
- Credit Risk Scorecards Credit Risk Modeling 评分卡 KS AR
https://cn.mathworks.com/help/finance/creditscorecard.validatemodel.html?requestedDomain=www.mathwor ...
- where 1=1影响效率以及having和where的区别
低效的“WHERE 1=1” 网上有不少人提出过类似的问题:“看到有人写了WHERE 1=1这样的SQL,到底是什么意 思?”. 其实使用这种用法的开发人员一般都是在使用动态组装的SQL. 让我们想像 ...