Submission #464345

#TimeUsernameProblemLanguageResultExecution timeMemory
464345KerimRack (eJOI19_rack)C++17
100 / 100
4 ms4044 KiB
#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; } //(a(n, k) = if( k<=0 || k>=n, 0, if( k%2, n\2) + a(n\2, k\2))); //{T(n, k) = if( k<=0 || k>2^n/2, 0, 1 + a(2^n/2, k-1))};

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...