|
|
вернуться в форумWA #3 Please Help what's wrong with my program Послано Rashad 5 май 2010 22:29 I didn't solve it by the easiest way.. This is my program, it gives right answers for my tests, but I have WA #3 , give me please this test #include <cstdlib> #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(int argc, char *argv[]) { long n,i,j,a; long na=65536; vector <long> pos,test; vector <long>:: iterator it; pos.push_back(1); pos.push_back(2); for (i=2;i<na;i++) { pos.push_back(pos[i-1]+i); } cin>>n; for (i=0;i<n;i++) { cin>>a; test.push_back(a); } sort(test.begin(),test.end()); j=0; for (i=0;i<n;i++) { while ((j<na) && (test[i]>pos[j])) { j++; } if (j==na) { cout<<"0 "; } else if (test[i]==pos[j]) { cout<<"1 "; } else { cout<<"0 "; } } cout<<endl; system("PAUSE"); return EXIT_SUCCESS; } Edited by author 05.05.2010 22:29 Re: WA #3 Please Help what's wrong with my program Послано Nevena 29 май 2011 07:05 Have you tried for large values for k? It possibly overflows |
|
|