==== 소감 ==== 2005/03/05 Accepted 0:00.074 64 1학년 때 풀어서 틀렸었던 문제를 다시 풀어보았다. 일단 이동곱셈의 규칙성을 연습장에 끄적이는 도중 쉽게 발견할 수 있었고, 간단히 사칙연산으로 구현할 수 있었다. 마지막 자리숫자가 0일 경우의 예외처리를 해 준 후 바로 통과. ==== 코드 ==== {{{~cpp // no550 - Multiplying by Rotation #include 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; } }}} ---- [MultiplyingByRotation] [문보창]