|
|
вернуться в форумwa #8 helppppppp pls Послано h1ci 24 ноя 2009 21:33 whats test 8 or whats wrong with that: #include<iostream> using namespace std; int main() { int n; cin >> n; char a[3]={'a','b','c'}; if(n*6>10000){ cout<<"TOO LONG" << endl; return 0;} if(n==1){ cout << "a\nb\nc\n"; return 0;} for(int i=0; i<n; i++) { cout << a[i%3]; } cout << endl; a[0]='a'; a[1]='c'; a[2]='b'; ////////////////////////////// for(int i=0; i<n; i++) { cout << a[i%3]; } cout << endl; a[0]='b'; a[1]='a'; a[2]='c'; ////////////////////////////// for(int i=0; i<n; i++) { cout << a[i%3]; } cout << endl; a[0]='b'; a[1]='c'; a[2]='a'; ////////////////////////////// for(int i=0; i<n; i++) { cout << a[i%3]; } cout << endl; a[0]='c'; a[1]='a'; a[2]='b'; ////////////////////////////// for(int i=0; i<n; i++) { cout << a[i%3]; } cout << endl; a[0]='c'; a[1]='b'; a[2]='a'; ////////////////////////////// for(int i=0; i<n; i++) { cout << a[i%3]; } cout << endl; return 0; } Re: wa #8 helppppppp pls Your problem is that line - if(n*6>10000){ cout<<"TOO LONG" << endl; return 0;} } Re: wa #8 helppppppp pls Послано h1ci 25 ноя 2009 16:29 whats wrong with that? If the output exceeds 10000 letters output "TOO LONG" ?!?! Re: wa #8 helppppppp pls Послано h1ci 25 ноя 2009 16:31 Oh, sorry my bad it's 100 000 not 10 000; AC now Edited by author 25.11.2009 16:33 Edited by author 25.11.2009 16:33 Edited by author 25.11.2009 16:33 Edited by author 25.11.2009 16:33 Edited by author 25.11.2009 16:33 STL is your friend (+) Послано ASK 4 апр 2010 18:47 Btw, instead of copy/pasting code for every permutation you can char a[] = "abc"; do{ F(i,n) cout << a[i%3]; cout << endl; }while(next_permutation(a,a+3)); where F is #define F(i,n) for(int i = 0; i < n; ++i) |
|
|