Đă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é!
@$\text{JoonHae}$
#include<bits/stdc++.h>
#define hutao long long
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
hutao n;
cin>>n;
hutao dem=0;
hutao p=3;
while(n/p>0)
{
dem+=(n/p);
p*=3;
}
cout<<dem-1;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
ll n,dem = 0;
cin>>n;
for(ll p=3;n/p>0;p*=3) {
dem+=n/p;
}
cout<<dem-1;
return 0;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin