Untitled
unknown
plain_text
2 years ago
912 B
7
Indexable
#include <iostream> using namespace std; int powE[201]; int divisor, tmpDivisor; void mu10() { powE[0] = 1; for(int i = 1; i < 201; i++){ powE[i] = (powE[i - 1] * 10) % tmpDivisor; } } bool isOK(int N, int K) { int res = 8*powE[N] - 2*powE[K] - 6; if(res % tmpDivisor == 0) return true; else return false; } int main() { //freopen("input.txt", "r", stdin); int T; cin >> T; for(int tc = 1; tc <= T; tc++){ cin >> divisor; tmpDivisor = 9 * divisor; mu10(); bool check = false; cout << "Case #" << tc << endl; for(int N = 1; N <= 200; N++){ for(int K = N; K >=0 ; K--){ if(isOK(N, K)){ for(int i = 1; i <= N - K; i++) cout << "8"; for(int i = 1; i <= K; i++) cout << "6"; check = true; K = -1; N = 201; } } } if(!check) cout << "-1"; cout << endl; } return 0; }
Editor is loading...