zju 2886

#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
 int i,n,m;
 string s;
 while(cin>>m)
 {
  while(m--)
  {
   cin>>s;
   n=1;
   if(s.size()==1) cout<<n<<s[0];
         for(i=0;i<s.size()-1;i++)
          if(s[i]==s[i+1]) n++;
          else {cout<<n<<s[i];n=1;}
            if(i=s.size()-1)
             cout<<n<<s[s.size()-1];
            cout<<endl;
  }
 }

 return 0;
}

#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
 int i,n,m;
 string s;
 while(cin>>m)
 {
  while(m--)
  {
   cin>>s;
   n=1;
   if(s.size()==1) cout<<n<<s[0];
         for(i=0;i<s.size()-1;i++)
          if(s[i]==s[i+1]) n++;
          else {cout<<n<<s[i];n=1;}
            if(i=s.size()-1)
             cout<<n<<s[s.size()-1];
            cout<<endl;
  }
 }
 
 return 0;
}

#include<iostream>
using namespace std;
#include<cstring>
#include<cstdio>
int main()
{
    int n,i,j,sum;
    char a[1005];
    while(cin>>n)
    {
        getchar();
        for(i=0;i<n;i++)
        {    cin>>a;
            sum=1;
            if(strlen(a)==1){ cout<<1<<a[0]<<endl;continue;}
            for(j=1;j<strlen(a);)
            {    while(a[j]==a[j-1]&&a[j]) {sum++;j++;}
                if(a[j]!=a[j-1])
                {    cout<<sum<<a[j-1];
                    sum=1;
                }
                if(a[j])
                {    if(a[j+1]==0) cout<<sum<<a[j];
                    j++;
                }
            }
            cout<<endl;
        }
    }
    return 0;
}

#include<iostream>

using namespace std;

#include<cstring>

#include<cstdio>

int main()

{

int n,i,j,sum;

char a[1005];

while(cin>>n)

{

getchar();

for(i=0;i<n;i++)

{ cin>>a;

sum=1;

if(strlen(a)==1){ cout<<1<<a[0]<<endl;continue;}

for(j=1;j<strlen(a);)

{ while(a[j]==a[j-1]&&a[j]) {sum++;j++;}

if(a[j]!=a[j-1])

{ cout<<sum<<a[j-1];

sum=1;

}

if(a[j])

{ if(a[j+1]==0) cout<<sum<<a[j];

j++;

}

}

cout<<endl;

}

}

return 0;

}

#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
 int n,i,sum;
 string s;
 cin>>n;
 while(n--)
 {
  cin>>s;
  for(i=0,sum=1;s[i];i++)
  {
   if(s[i]==s[i+1]) sum++;
   else
   {
    cout<<sum<<s[i];
    sum=1;
   }
  }
  cout<<endl;
 }
 return 0;
}

#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
 int n,i,sum;
 string s;
 cin>>n;
 while(n--)
 {
  cin>>s;
  for(i=0,sum=1;s[i];i++)
  {
   if(s[i]==s[i+1]) sum++;
   else
   {
    cout<<sum<<s[i];
    sum=1;
   }
  }
  cout<<endl;
 }
 return 0;
}

zju 2886,布布扣,bubuko.com

时间: 2024-10-27 19:12:41

zju 2886的相关文章

poj 2886 Who Gets the Most Candies?

Problem: 2886 User: shu_dayang Memory: 11104K Time: 1125MS Language: C++ Result: Accepted #include<iostream> #include<cstdio> #include<cstring> #define MID(a,b) ((a + b) >> 1) using namespace std; const int MAXN = 500005; int sum[M

poj 2886 Who Gets the Most Candies? (线段树单点更新应用)

poj 2886 Who Gets the Most Candies? Description N children are sitting in a circle to play a game. The children are numbered from 1 to N in clockwise order. Each of them has a card with a non-zero integer on it in his/her hand. The game starts from t

HDU 4800 &amp; ZJU 3735 Josephina and RPG(状压dp)

题目链接: ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5081 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=4800 Problem Description A role-playing game (RPG and sometimes roleplaying game) is a game in which players assume the roles of c

ZJU 2676 Network Wars

Network Wars Time Limit: 5000ms Memory Limit: 32768KB This problem will be judged on ZJU. Original ID: 267664-bit integer IO format: %lld      Java class name: Main Special Judge Network of Byteland consists of n servers, connected by m optical cable

poj 2886 Who Gets the Most Candies?(线段树+约瑟夫环+反素数)

Who Gets the Most Candies? Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 9934   Accepted: 3050 Case Time Limit: 2000MS Description N children are sitting in a circle to play a game. The children are numbered from 1 to N in clockwise o

zju 1763

#include <iostream> #include <cstdio> using namespace std; int main(int argc, char *argv[]) { double a,b; cin>>a; while (cin>>b) { if (b==999) { printf("End of Output\n"); break; } printf("%.2f\n",(b-a)); a=b; }

人生第一场组队赛---2014.8 zju monthly

暑期集训中段就组了队,不过一直没机会打比赛 昨天kitkat突然发现了zju要搞月赛,我想了一下题目对于我这种渣实在是有点难,于是想到干脆打一次组队赛吧,跟队友商量了一下也同意了 12点---17点  5小时 10道题 虽然难度比一般现场赛低一些 不过形式上差不多 应该还算一次不错的练习机会 比赛开始 zh0ng神从前往后读,kitkat从后往前读,我则在中间乱看 我先看了E,感觉是个dp,但是又有点模糊,kitkat读了J,一个字符串题,题意很简单,可是也没什么好的解决办法(最后发现j是全场最

zju 2744 回文字符 hdu 1544

#include<iostream> #include<algorithm> using namespace std; int main() { string s; while(cin>>s) { int i,begin,end,total = s.size(),l = s.size(); for(i = 0 ; i < s.size(); ++i) { begin = i - 1; end = i+1;//当字符串长度为奇数时 while(s[begin]==s

zju 1251 Bricks box 砖盒----------hdu 1326

#include <iostream> using namespace std; int main() { int a[51],n,k=1; while(cin>>n,n) { int i,ans=0,s=0; for(i=0;i<n;i++) { cin>>a[i]; s+=a[i]; } s/=n; for(i=0;i<n;i++) if(a[i]>s)ans+=a[i]-s; cout<<"Set #"<&l