이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod=1e9+7;
int poww(int a, int b)
{
if(b==0) return 1;
int tmp=poww(a, b/2);
if(b%2==0) return (tmp*tmp)%mod;
else return (((tmp*tmp)%mod)*a)%mod;
}
int sum(int a, int b)
{
return ((((a+b)%mod)+mod)%mod);
}
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
int n, k; cin>>n>>k;
n--;
int ans=1;
while(n>=0)
{
if(k%2==0) ans=sum(ans, poww(2, n)), k/=2;
else k++, k/=2;
n--;
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |