开场白

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0


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

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

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

 

Input
第一行一个正整数 T (T10) 表示数据组数。
对于每组数据,一行一个正整数 n (1n10100000)
 

 

Output
对于每组数据,Yes 表示 n 是若干个 2050 依次拼接起来的,No 表示不是。
 

 

Sample Input
2
2050
205020

Sample Output

Yes
No

 

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <string>
 4 
 5 
 6 using namespace std;
 7 
 8 int main()
 9 {
10     int t;
11     cin>>t;
12     while(t--)
13     {
14         string str;
15         cin>>str;
16         int num=0;
17         int i;
18         for(i=0;str[i];i++)
19         {
20             num++;
21             if(num==1)
22             {
23                 if(str[i]!='2')
24                     break;
25             }
26             else if(num==2)
27             {
28                 if(str[i]!='0')
29                     break;
30             }
31             else if(num==3)
32             {
33                 if(str[i]!='5')
34                     break;
35             }
36             else if(num==4)
37             {
38                 if(str[i]!='0')
39                     break;
40                 else num=0;
41             }
42         }
43         if(str[i]==0&&num==0)
44             cout<<"Yes"<<endl;
45         else 
46             cout<<"No"<<endl;
47     }
48     return 0;
49 }

 

posted @ 2019-04-13 22:35  jiamian22  阅读(149)  评论(0编辑  收藏  举报