POJ 3438 Look and Say(水题)

【题意简述】:就是说一串数字,现在让我们换一种方式去描述它,用该数字的个数和数字本身去重新描述这串数字。

【分析】:简单模拟一下。

//248k  641ms
#include<iostream>
using namespace std;

int main()
{
	int t;
	char digits[1001];
	cin>>t;
	while(t--)
	{
		cin>>digits;
		int len = strlen(digits);
		int count = 1;
		for(int i = 0;i<len;i++)
		{
			if(digits[i] == digits[i+1])
				count++;
			else{
				cout<<count<<digits[i];
				count = 1;
			}
		}
		cout<<endl;
	}
	return 0;
}
时间: 2024-10-10 21:48:36

POJ 3438 Look and Say(水题)的相关文章

POJ 3030. Nasty Hacks 模拟水题

Nasty Hacks Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13136   Accepted: 9077 Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of malicious software which teenagers may use to fool their friends.

poj 3444 Wavelet Compression 模拟水题

水题,直接贴代码. //poj 3444 //sep9 #include <iostream> using namespace std; const int maxN=260; int a[maxN],b[maxN]; int main() { int i,n,m; while(scanf("%d",&n)==1&&n){ for(i=1;i<=n;++i) scanf("%d",&a[i]); m=1; while

【POJ】Cow Multiplication(水题)

Cow Multiplication http://poj.org/problem?id=3673 题意:输入两个数A B,比如123和45   然后算123*45这个运算是指1*4 + 1*5 + 2*4 + 2*5 + 3*4 + 3*5 = 54. 思路:水题. #include<iostream> #include<cmath> #include<cstring> using namespace std; typedef long long ll; const

poj 1004:Financial Management(水题,求平均数)

Financial Management Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 126087   Accepted: 55836 Description Larry graduated this year and finally has a job. He's making a lot of money, but somehow never seems to have enough. Larry has deci

POJ 2656 Unhappy Jinjin(水题)

[题意简述]:找到两数之和最大的那一天. [分析]:这个....代码就贴在题目下啊. #include <stdio.h> int main(){ while(1) { int i, n; int maxday, maxvalue = -1; scanf("%d", &n); if (n == 0) break; for (i = 1; i <= n; i++) { int a, b; scanf("%d%d", &a, &

ACM: POJ 1401 Factorial-数论专题-水题

POJ 1401 Factorial Time Limit:1500MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Description The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term

POJ 1986 DIstance Query LCA水题

给出一棵树,对于每一个询问,给出2个节点,输出2个节点的距离. 输入中有字母,那个是没有用的,不用管. 思路: 0.选择编号为1的节点作为树的root (注意:有些题的边是单向的,这时候我们要根据节点的入度来确定root, 双向的话一般可以随意选择一个节点作为root) 1.dfs1,求出dep和pa[i][0] 2.初始化数组pa 3.节点(u,v)的权值为w 把本来是边的权值w赋给u,v中dep较大的节点, cost[i]表示节点i的权值为cost[i] 先初始化:cost[root]=0

【POJ 2503】Babelfish(水题)stl map存取即可

题目链接 题目链接 http://poj.org/problem?id=2503 题意 英文A <=> 方言B 输入B,求A 代码如下(G++) #include <iostream> #include <string.h> #include "map" #include "string" using namespace std; typedef long long ll; double eps = 1e-7; map <s

POJ 2234 Matches Game 博弈论水题 Nim模型

Description Here is a simple game. In this game, there are several piles of matches and two players. The two player play in turn. In each turn, one can choose a pile and take away arbitrary number of matches from the pile (Of course the number of mat

POJ 1595 素数打表水题

[题意简述]:给出N和C,让我们求出N以内的包括N的素数,然后根据若N以内的素数为奇数个,就将中间2*c-1个素数输出:若为偶数个,就将中间2*c个素数输出. [分析]:只要题意理解就简单了. 详见代码: // 224K 16Ms #include<iostream> using namespace std; #define N 2000 bool isprime[N]; int prime[N],nprime; void doprime(int n) { int i,j; nprime =