Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么总是不能ACC, 恳请高手相助:#include <vector> #include <algorithm> #include <math.h> #include <iostream> using namespace std; bool Judge(vector<int> &vec) { int i; for( i = 0; i < vec.size()-1; i++) { vec.at(i) = abs(vec.at(i)-vec.at(i+1)); } sort(vec.begin(), vec.end()); for(i = 0; i < vec.size()-1; i++) { if(vec.at(i) != i+1) return false; } return true; } void Problem(vector<int> &vec) { int n; int dat; scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%d", &dat); vec.push_back(dat); } if(Judge(vec)) cout << "Jolly" << endl; else cout << "Not jolly" << endl; } int main() { vector<int> vec; Problem(vec); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator