Codeforces Beta Round #36 / 36A Extra-terrestrial Intelligence(模拟)
来源:互联网 发布:四舍五入数据 英文 编辑:程序博客网 时间:2024/05/19 23:13
Recently Vasya got interested in finding extra-terrestrial intelligence. He made a simple extra-terrestrial signals’ receiver and was keeping a record of the signals for n days in a row. Each of those n days Vasya wrote a 1 in his notebook if he had received a signal that day and a 0 if he hadn’t. Vasya thinks that he has found extra-terrestrial intelligence if there is a system in the way the signals has been received, i.e. if all the intervals between successive signals are equal. Otherwise, Vasya thinks that the signals were sent by some stupid aliens no one cares about. Help Vasya to deduce from the information given by the receiver if he has found extra-terrestrial intelligence or not.
The first line contains integer n (3 ≤ n ≤ 100) — amount of days during which Vasya checked if there were any signals. The second line contains n characters 1 or 0 — the record Vasya kept each of those n days. It’s guaranteed that the given record sequence contains at least three 1s.
If Vasya has found extra-terrestrial intelligence, output YES, otherwise output NO.
800111000
YES
71001011
NO
71010100
YES
水。
完整代码:
/*30ms,100KB*/#include<cstdio>int main(){int n, count = 0, interval = 0;bool is_intelligence = true;freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);scanf("%d", &n);getchar();while (n--){if (getchar() == '1')break;}while (n--){if (getchar() == '0')interval++;elsebreak;}while (n--){if (getchar() == '0')count++;else{if (count == interval)count = 0;else{is_intelligence = false;break;}}}printf(is_intelligence ? "YES" : "NO");return 0;}
- Codeforces Beta Round #36 / 36A Extra-terrestrial Intelligence(模拟)
- 【读入】#36 A. Extra-terrestrial Intelligence
- A - Extra-terrestrial Intelligence
- A. Extra-terrestrial Intelligence
- Extra-terrestrial Intelligence
- Codeforces Beta Round #36 / 36B Fractal(分形&模拟)
- Codeforces Beta Round #10 / 10A Power Consumption Calculation (模拟)
- Codeforces Beta Round #10 A. Power Consumption Calculation (模拟)
- Codeforces Beta Round #35 (Div. 2) / 35A Shell Game(模拟)
- Codeforces Beta Round #98 (Div. 2) / 137A Postcards and photos (模拟)
- Codeforces Beta Round #92 (Div. 2) / 124A The number of positions 【简单模拟】【水题】
- Codeforces Beta Round #2 A map B dp C 模拟退火
- Codeforces Beta Round #1(A,B)
- Codeforces Beta Round #1 A B C
- Codeforces Beta Round #47 A题
- Codeforces Beta Round #90 A题
- Codeforces Beta Round #1 A题
- Codeforces Beta Round #1 A B C
- 打印的3种方式
- 网络技术学习(java script & html)
- 新页面的CSS Reset
- 唯一性索引优化实践(讲得好细哦)
- IOS---VM ware9.0安装 10.8 Mountain Lion +Xcode4.6.5(一)
- Codeforces Beta Round #36 / 36A Extra-terrestrial Intelligence(模拟)
- 图片按钮 CSS
- QQ2013手工去广告
- hdu(1563)Find your present!
- android开发之应用编程
- Android Tombstone/Crash的log分析和定位
- hdu 4678 Mine(博弈SG,4级)
- MPMoviePlayerController 视频播放器—IOS开发
- 如何签名发布软件