This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
#define MAXN 1000009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x) cerr<< #x <<" = "<< x<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int pw[MAXN],N;
ll K;
int mod(int x){
if(x>=INF)x-=INF;
return x;
}
int a(int n,ll k,int res=1){
while(k)res=mod(res+(k%2)*pw[n--]),k/=2;
return res;
}
int main(){
//~ freopen("file.in", "r", stdin);
scanf("%d%lld",&N,&K);pw[0]=1;
for(int i=1;i<=N;i++)pw[i]=mod(pw[i-1]+pw[i-1]);
printf("%d\n",a(N-1,K-1));
return 0;
}
Compilation message (stderr)
rack.cpp: In function 'int main()':
rack.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
32 | scanf("%d%lld",&N,&K);pw[0]=1;
| ~~~~~^~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |