|
|
вернуться в форумThere is my supervisions about this task. The condition of the task is really bad. For example, test 8, broadly speaking, is not suitable with task conditioon. Here is my solution. #include <iostream> using namespace std; int main() { int n = 0; char s[1000]; gets(s); int k = strlen(s); if ((s[0] == '1') && (s[1] == '0')) { n = 10; k += -3; } else { n = s[0] - '0'; k += -2; } if ((k <= 0)||(n - k <= 0)) { cout << n; return 0; } long long tmp = (long long)n; int i = 1; if (n % k != 0) { while (1) { tmp *= (n - i*k); if (n % k == n - i*k) { break; } else { i++; } } } else { while (1) { tmp *= (n - i*k); if (k == n - i*k) { break; } else { i++; } } } cout << tmp; return 0; } |
|
|