Đăng nhập để hỏi chi tiết


Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
Ý tưởng: mình chỉ cần duyệt cấu trúc rẽ nhánh theo
VT: VN: XT: XN = 9 : 3 : 3 : 1
#include <bits/stdc++.h>
using namespace std;
void solve()
{
long long n;
string s;
cin >> s >> n;
if (s == "VT") cout << n << " " << n / 3 << " " << n / 3 << " " << n / 9;
else if (s == "VN") cout << n * 3 << " " << n << " " << n << " " << n / 3;
else if (s == "XT") cout << n * 3 << " " << n << " " << n << " " << n / 3;
else cout << n * 9 << " " << n * 3 << " " << n * 3 << " " << n;
}
signed main() {
int tt = 1;
//cin >> tt;
while (tt--) solve();
return 0;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
void solve() {
lli n;
string s;
cin >> s >> n;
int mul[4];
while (true) {
if (s == "VT") {
mul[0] = 1;
mul[1] = 1 / 3.0;
mul[2] = 1 / 3.0;
mul[3] = 1 / 9.0;
break;
} else if (s == "VN" || s == "XT") {
mul[0] = 3;
mul[1] = 1;
mul[2] = 1;
mul[3] = 1 / 3.0;
break;
} else {
mul[0] = 9;
mul[1] = 3;
mul[2] = 3;
mul[3] = 1;
break;
}
}
cout << static_cast<long long>(n * mul[0]) << " "
<< static_cast<long long>(n * mul[1]) << " "
<< static_cast<long long>(n * mul[2]) << " "
<< static_cast<long long>(n * mul[3]) << endl;
}
signed main() {
int tt = 1;
//cin >> tt;
while (tt--) solve();
return 0;
}
Đây nha cậu.
Chúc cậu học tốt :3
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin