首页 > 其他分享 >文件解压 //problem/2928 or /contest/1709/problem/3

文件解压 //problem/2928 or /contest/1709/problem/3

时间:2023-08-16 17:56:44浏览次数:31  
标签:2928 string contest int 1709 problem

字符串套 递归

#include<bits/stdc++.h>
using namespace std;
char s[1005];
int n,i;
string work(){
    string p; int t = 0;
    while(++i <= n){
        if(s[i] >= '0' && s[i] <= '9'){
            t = s[i] - '0';
        }
        else if(s[i] == '('){
            string pp = work();
            while(t--) p += pp;
            t = 0;
        }
        else if(s[i] == ')') return p;
        else p += s[i];        
    }
    return p;
}
int main(){
    cin>>s+1; n = strlen(s+1);
    cout<<work();
    return 0;
}

zgy:

 rty

 

 

 

标签:2928,string,contest,int,1709,problem
From: https://www.cnblogs.com/caterpillor/p/17635809.html

相关文章

  • CF1858C Yet Another Permutation Problem 题解
    思路这个题是一个简单的构造题。竟然比T2简单,也是少见我们可以首先从\(1\)开始不断乘以\(2\),像这样:\(1,2,4,8,16\cdots,2^x\),直到什么时候超过\(n\)就停止。这样相邻两个数字就可以凑出\(1,2,4,6,\cdots,2^{x-1}\),保证两两不同。然后我们可以从\(3\)开始不......
  • CF1858C Yet Another Permutation Problem 题解
    杂言赛时想到做法,结果调code把自己心态调炸了,所以来写一篇题解(恼)。另:此题与P9345夕阳西下几时回几乎相同,可以此练手。另另:本题多测,多测不清空,爆零两行泪。题意翻译\(a_1,a_2,\dots,a_n\)是\(1\)至\(n\)的一个排列,记\(d_i=\gcd(a_i,a_{i\bmodn+1})\)。构造一个......
  • CF776D The Door Problem
    题目大意给定门和钥匙的数量,每把钥匙控制\(k_i\)扇门,每扇门被两把钥匙控制。给定初始时每扇门的状态,求是否存在一种方法使得所有的门都打开。思路扩展域并查集。考虑分类讨论:对于开着的门,要么两把钥匙都用,要么两把钥匙都不用;对于关着的门,两把钥匙只能用一把。那么我们......
  • 胡萝卜问题 Carrot Problems
    Refhttps://www.atvbt.com/the-carrot-problem/......
  • AtCoder Beginner Contest 314
    AtCoderBeginnerContest314-AtCoderA-3.14(atcoder.jp)题目提供了100位,所以直接用字符串输出#include<bits/stdc++.h>#defineintlonglongusingnamespacestd;signedmain(){ios::sync_with_stdio(false);cin.tie(nullptr);strings="3.14......
  • AtCoder Beginner Contest 314
    AtCoderBeginnerContest314-AtCoderA3.14voidsolve(){strings="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679";intn;cin>>n;cout<<s.substr(0,n......
  • Contest1319 - 期末习题汇总(二) 计算机基础---进制转换相关
    题目描述将十进制的1234输出将八进制的1234对应其十进制数进行输出将十六进制的1234对应其十进制数进行输出输入无输出1234D=1234D1234O=668D1234H=4660D样例输出1234D=1234D1234O=668D1234H=4660D 代码:#include<iostream>#include<iomanip>usingnamespacestd;in......
  • AtCoder Beginner Contest 314 A - Ex题解
    AtCoderBeginnerContest314A-3.14嗯,你可以用string存小数点后的...B-Roulette对于每一个金额,用个vector存pair<>存一个人赌了多少,以及是哪一个人。C-RotateColoredSubsequence每种数用个双向链表记下来。D-LOWER我们观察到,对于2,3操作,只有最后一次有用,且......
  • AtCoder Beginner Contest 214
    AtCoderBeginnerContest214-AtCoder [ABC214D]SumofMaximumWeights ------------------------------(典)题意:给出一颗N-1 条边的树,求树上任意两点间路径上的最大值的和这种问题考虑每条边单独看贡献,但是刚开始没太想明白怎么计算贡献,后面看了洛谷题解才懂了-......
  • AtCoder Beginner Contest 313
    AtCoderBeginnerContest313A-ToBeSaikyo思路:找到最大的,和第一个比较#include<bits/stdc++.h>usingnamespacestd;#defineintlonglong//#defineint__int128#definedoublelongdoubletypedefpair<int,int>PII;typedefpair<string,int>PSI;t......