一开始超时了
#include <iostream> #include <string> using namespace std ; int main() { int t ; cin >> t ; while (t--) { int n ; cin >> n ; string s ; for ( int i = n ; i >=0 ; --i) { if ( i%3 == 0 && (n-i) %5 == 0) { for(int j=0;j<i;++j) s+='5'; for(int j=0;j<n-i;++j) s+='3'; break; } } if (s=="") cout << "-1" << endl ; else cout << s << endl ; } return 0 ;