Submission #288498

#TimeUsernameProblemLanguageResultExecution timeMemory
288498BenmathRack (eJOI19_rack)C++14
0 / 100
1 ms256 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; long long int k; cin>>k; long long int step[n+1]; long long int mod=10e8+7; k=k%mod; step[0]=1; for(int i=1;i<=n;i++){ step[i]=(step[i-1]*2)%mod; } if(k==1){ cout<<1; }else{ if(k==2){ cout<<step[n-1]+1; }else{ long long int y; if(k%2==0){ y=(k-2)/2; }else{ y=(k-1)/2; } long long int ti; long long int li; long long int step1=1; long long int mi=0; for(int i=1;i<=n;i++){ if(i!=1){ step1=(step1*2)%mod; mi++; } if((y-step1)<step1){ ti=step1; li=y-step1; break; } } long long int a1=step[n-2-mi] ; li=li%mod; long long int b=(2*li+1)%mod; long long int res=(a1*b+1)%mod; if(k%2==0){ res=(res+step[n-1])%mod; } cout<<res; } } }

Compilation message (stderr)

rack.cpp: In function 'int main()':
rack.cpp:29:23: warning: variable 'ti' set but not used [-Wunused-but-set-variable]
   29 |         long long int ti;
      |                       ^~
rack.cpp:48:11: warning: 'li' may be used uninitialized in this function [-Wmaybe-uninitialized]
   48 |         li=li%mod;
      |         ~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...