¶
2005/03/05 Accepted 0:00.074 64
1 문를 보. 동 는 , . 마막 리 0 리를 바 .
1 문를 보. 동 는 , . 마막 리 0 리를 바 .
¶
~cpp // no550 - Multiplying by Rotation #include <iostream> using namespace std; int main() { int base, lsd, factor; // , 마막리, int carryIn, carryOut; int temp; int nDigit; while (cin >> base >> lsd >> factor) { if (lsd == 0) { cout << "1\n"; continue; } temp = lsd; carryIn = (temp * factor) / base; temp = (temp * factor) % base; nDigit = 2; while (true) { carryOut = (temp * factor + carryIn) / base; temp = (temp * factor + carryIn) % base; if (carryOut == 0 && temp == lsd) { cout << nDigit << endl; break; } nDigit++; carryIn = carryOut; } } return 0; }