|
|
back to boardcan't go past test # 3 Am I making it too complicated ? can anyone tell me what's wrong with the logic ? 9 !! works ok ............. #include "stdafx.h" #include <iostream> #include <string> using namespace std; int main() { int n; string marks; int output = 1; cin >> n >> marks; int k= marks.length(); int until = n / k; if (n % k != 0) { for (int i = 0; i <= until; i++) { output *= (n - i * k); } output *= (n % k); } else if (n % k == 0) { for (int i = 0; i < k; i++) { output *= (n - i * k); } output *= k; } cout << output << endl; return 0; } Edited by author 06.08.2016 07:38 |
|
|