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 |
ftIn Reply To:求模了怎么还TLE啊……救救我!…… Posted by:00448028 at 2005-05-10 23:03:45 > 还有哪里会导致超时呢??焦头烂额了…… > > #include <iostream> > #include <string> > using namespace std; > > void main() > { > unsigned long n, k, i, j; > while( cin >> n && n != 0 ) > { > unsigned long *a = new unsigned long[n]; > for( i = 0; i < n; i ++ ) > cin >> a[i]; > while( cin >> k && k != 0 ) > { > cin.ignore(); > string str(n, 32); > for( i = 0; i < n; i ++ ) > { > char temp = cin.get(); > if( temp == '\n' ) > break; > else str[i] = temp; > } > string str1(str); > for( j = 1; j <= k; j ++ ) > { > string temp(n, 32); > for( i = 0; i < n; i ++ ) > temp[a[i] - 1] = str1[i]; > str1.assign(temp); > if( str1 == str ) //已经求模了 > { > k %= j; > j = 0; > } > } > cout << str1 << endl; > } > delete[]a; > cout << endl; > } > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator