HDU-2017"百度之星"程序设计大赛-复赛-1001-Arithmetic of Bomb

来源:互联网 发布:明年今日歌词解析知乎 编辑:程序博客网 时间:2024/06/16 00:02

ACM模版

描述

描述
描述

题解

这个题是签到题,出的不好,描述不到位。或者就是数据比较弱?第二个数字是个位数……那就很水了。

代码

#include <iostream>#include <cstring>using namespace std;const int MAXN = 1111;const int MOD = 1e9 + 7;char s[MAXN];int main(int argc, const char * argv[]){    int T;    cin >> T;    while (T--)    {        scanf("%s", s);        int len = (int)strlen(s);        long long ans = 0;        for (int i = 0; i < len; i++)        {            if (s[i] == '(')            {                int k = i + 1;                while (s[k] != ')')                {                    k++;                }                k++;                while (s[k] != ')')                {                    k++;                }                int cnt = s[k - 1] - '0';                while (cnt--)                {                    for (int j = i + 1; j < k - 4; j++)                    {                        ans = (ans * 10 + s[j] - '0') % MOD;                    }                }                i = k;            }            else            {                ans = (ans * 10 + s[i] - '0') % MOD;            }        }        printf("%lld\n", ans);    }    return 0;}
阅读全文
0 0
原创粉丝点击