Now given everyday‘s distances that one rides for N days, you are supposed to find the corresponding E (≤ N).
Each input file contains one test case. For each case, the first line gives a positive integer N (≤), the days of continuous riding. Then N non-negative integers are given in the next line, being the riding distances of everyday.
For each case, print in a line the Eddington number for these N days.
10 6 7 6 9 3 10 8 2 7 8
6
【不知道这题想干啥,让我一度怀疑自己中文水平都有问题】
【理解题意之后,2分钟就写完了,然而最后一个测试点WA]
1 #include<bits/stdc++.h> 2 using namespace std; 3 4 int main() 5 { 6 int n, cnt = 0; cin >> n; 7 for(int i = 1; i <= n; i++) 8 { 9 int x; cin >> x; 10 if(x > i) cnt++; 11 } 12 cout << cnt; 13 return 0; 14 }
PAT 甲级 1117 Eddington Number (25分)
原文:https://www.cnblogs.com/kamisamalz/p/13586419.html