Editorial for VM 08 Bài 08 - Kiến
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Lưu ý: Các code mẫu dưới đây chỉ mang tính tham khảo và có thể không AC được bài tập này
Code mẫu của flashmt
#include <iostream> using namespace std; int main() { long long m,n,x; cin >> n >> m; x=m*n; while (x>n) x=x+(x-n-1)/(m-1)-n; cout << x << endl; }
Code mẫu của RR
#include <iostream> using namespace std; int main() { long long n,m,p; cin >>n >>m; p=m*n; while (p>n) p+=(p-n-1)/(m-1)-n; cout<<p; return 0; }
Code mẫu của hieult
#include <stdio.h> //#include <conio.h> #include <iostream> //long long K,L; using namespace std; int main () { //freopen("10.in","r",stdin); long long M, N, result; scanf("%lld %lld",&N,&M); result = M * N; while (result > N) result += (result - N - 1)/(M - 1) - N; cout << result; //getch(); return 0; }
Comments