2050第一题-开场白 (HDU

来自世界各地的年青人在 https://2050.org.cn 握手团聚, 他们是航空航天的新生代,编程大赛的优胜者,35岁以下的创新者,科技公司的创始人,展望未来的科学家,天马行空的艺术家...... TA们期待在这里与所有人分享交流,给彼此灵感,给未来答案。

我们想要用10个题目,大声喊出年青人的声音。我们希望和大家一起用技术创造一个更好的2050。

第一道题目,我们来玩一个数字游戏。
给出一个数字 nn,我们想知道 nn 是不是若干个 2050 依次拼接起来的。

Input第一行一个正整数 T (T10)T (T≤10) 表示数据组数。
对于每组数据,一行一个正整数 n (1n10100000)n (1≤n≤10100000)。
Output对于每组数据,Yes 表示 nn 是若干个 2050 依次拼接起来的,No 表示不是。Sample Input

2
2050
205020

Sample Output

2
2050
205020
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
using namespace std;

string n;
int t;

int main()
{
    scanf("%d", &t);
    while(t--)
    {
        cin>>n;
        int sum = 0, flag = 1;
        int len = n.size();
        if(len%4 != 0)flag = 0;
        else
        {
            for(int i = 0; i<len-4; i += 4)
            {
                if(n[i] != '2' || n[i+1] != '0' || n[i+2] != '5' || n[i+3] != '0')
                {
                    flag = 0;
                    break;
                }
            }
        }
        if(flag)printf("Yes
");
        else printf("No
");
    }
    return 0;
}
原文地址:https://www.cnblogs.com/RootVount/p/10939718.html