zju 2478

-#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
   {
    if(sum==1)
     cout<<s[i];
    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
   {
    if(sum==1)
     cout<<s[i];
    else
     cout<<sum<<s[i];
    sum=1;
   }
  }
  cout<<endl;
 }
 return 0;
}

#include<iostream>
using namespace std;
#include<cstring>
#include<cstdio>
int main()
{
    int n,i,j,sum;
    char a[105];
    cin>>n;
    getchar();
    for(i=0;i<n;i++)
    {    cin>>a;
        sum=1;
        for(j=1;j<strlen(a);)
        {    while(a[j]==a[j-1]&&a[j]) {sum++;j++;}
            if(a[j]!=a[j-1])
            {    if(sum==1) cout<<a[j-1];
                else
                {    cout<<sum<<a[j-1];}
                sum=1;
            }
            if(a[j])
            {    if(a[j+1]==0) cout<<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[105];

cin>>n;

getchar();

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

{ cin>>a;

sum=1;

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

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

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

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

else

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

sum=1;

}

if(a[j])

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

j++;

}

}

cout<<endl;

}

return 0;

}

zju 2478,布布扣,bubuko.com

时间: 2024-11-10 07:36:50

zju 2478的相关文章

POJ 2478 欧拉函数(欧拉筛法) HDU 1576 逆元求法

相关逆元求法,我之前有写过,还有欧拉函数的求法,欧拉函数与逆元的关系  点击 POJ 2478 又是一个打表的题目,一眼看出结果就是前n个欧拉函数值的和. 这里直接计算欧拉函数值求和会超时,看见多组数据. 然后就是计算欧拉函数,打表就好了. #include <stdio.h> #include <string.h> #include <iostream> using namespace std; typedef long long LL; const int N =

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

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

zju 1115 Digital roots 数字根

#include <iostream> #include <string> using namespace std; int main() { string n; while(cin>>n,n!="0") { int s=0,l=n.length(); for(int i=0;i<l;i++) s+=n[i]-'0'; while(s>9) s=s/10+s%10; cout<<s<<endl; } return

zju 1188 DNA Sorting

#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; struct node { int a; char s[105]; }p[105]; int cmp(node c,node b) { return c.a<b.a; } int main() { int m,n; int t; scanf("%d",&t); //printf(&q