首页 > 其他分享 >HDU 1020 Encoding

HDU 1020 Encoding

时间:2024-07-26 16:20:26浏览次数:6  
标签:HDU 1020 Encoding int len include

题目链接:HDU 1020【Encoding】



思路

       简单模拟,计算相同字母的连续子串个数。


代码

#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long
const int N = 500 + 10;

void solve() {
  string s;
  cin >> s;
  int len = s.length();
  for (int i = 0; i < len; i++) {
    int j = i;
    while (s[i] == s[j] && j < len)
      j++;
    if (j - i != 1) cout << j - i;
    cout << s[i];
    i = j - 1;
  }
  cout << endl;
  return;
}

int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

标签:HDU,1020,Encoding,int,len,include
From: https://www.cnblogs.com/againss/p/18325606

相关文章

  • 数字化时代下高校程序设计类课程综合实践平台-计算机毕业设计源码41020
    摘要在数字化时代浪潮的推动下,高校程序设计类课程的教学与实践面临着前所未有的挑战与机遇。为适应这一时代变革,培养具备创新能力和实践精神的高素质程序设计人才,综合实践平台的设计与开发显得尤为重要。本文旨在探讨高校程序设计类课程综合实践平台的设计与开发,通过深入分析......
  • HDU多校 2024R1
    T1把\(A\)的所有循环位移哈希一下扔set里,拿\(B\)的所有长为\(|A|\)的子串查一遍即可。代码#include<iostream>#include<set>usingnamespacestd;set<unsignedlonglong>st;constintB=2333;unsignedlonglongpw[2000005];intmain(){inttc;......
  • HDU1000,HDU1001,HDU1002,HDU1003,HDU1004
    目录HDU1000——A+BProblem题目描述运行代码代码思路HDU1001——SumProblem题目描述运行代码代码思路HDU1002——A+BProblemII(高精度加法)题目描述运行代码代码思路高精度加法模板HDU1003——MaxSum题目描述运行代码代码思路HDU1004——LettheBall......
  • hdu2601
    /*题意:给n求满足i*j+i+j=n(0<i<=j)方案数思路:xy+x+y=n(x+1)(y+1)=x*y+x+y+1=n+1;即求n+1的因子对数参考:https://blog.csdn.net/Puppettt/article/details/83030925?ops_request_misc=%257B%2522request%255Fid%2522%253A%25221720964219168001821369......
  • MBR10200CT-ASEMI智能AI应用MBR10200CT
    编辑:llMBR10200CT-ASEMI智能AI应用MBR10200CT型号:MBR10200CT品牌:ASEMI封装:TO-220批号:最新恢复时间:35ns最大平均正向电流(IF):10A最大循环峰值反向电压(VRRM):200V最大正向电压(VF):0.70V~0.90V工作温度:-65°C~175°C芯片个数:2芯片尺寸:mil正向浪涌电流(IFMS):150AMBR10200CT特性:......
  • HDU 1213 How Many Tables
    题目链接:HDU1213HowManyTables思路    经典并查集,将互相认识的人全部放在一个集合内,然后计算有几个集合就有几个桌子。代码#include<iostream>usingnamespacestd;#definelllonglongconstintN=1e3+10;intfa[N];voidinit(intn){for(i......
  • HDU 2570 迷瘴
    题目链接:HDU2570【迷障】思路    简单贪心,需要算出尽可能大的体积,所以先将浓度数组按从小到大的顺序排列,然后从小到大依次取出药水配置,直到浓度大于w,回溯到前一个状态并输出代码#include<bits/stdc++.h>#include<exception>usingnamespacestd;#definelllo......
  • HDU 2037 今年暑假不AC
    题目链接:HDU2037【今年暑假不AC】’思路    典型区间贪心,按节目结束时间升序排序,结束时间相等时按开始时间升序排序,然后逐个查找满足要求的节目,下一个观看的节目开始时间要大于当前观看节目的结束时间。代码#include<bits/stdc++.h>usingnamespacestd;#define......
  • HDU 1240 Asteroids!
    题目链接:HDU1240【Asteroids!】思路    代码#include<iostream>#include<queue>#include<stdlib.h>#include<cstring>#definelllonglongusingnamespacestd;constintN=20;constintM=1e4;structpoint{intx,y,z,st......
  • HDU 1312 RED AND BLACK
    题目链接:HDU1312【REDANDBLACK】思路    简单搜索,输入数据时,找出起点位置,然后从七点位置开始搜素能到达的所有位置并记录,使用check()函数判断当前位置可以走吗,可以走就把当前位置放入队列中,并将当前位置修改为非黑色位置,防止重复进入。代码#include<bits/stdc+......