#include <iostream> using namespace std; int main() { int a[15] = { 0,0,1,7,4,2,6,8,16,18,22,26,28,68,88 }; int t, n; cin >> t; while (t--) { cin >> n; int res=0; if (n <= 14) { res += a[n]; } else { res = a[n % 7 + 7]; int temp = n / 7 - 1; while (temp--) { res = res * 10 + 8; } } cout << res << endl; } } |
Double click to view unformatted code.