Submission #337432

# Submission time Handle Problem Language Result Execution time Memory
337432 2020-12-20T18:42:46 Z MilosMilutinovic Rack (eJOI19_rack) C++14
100 / 100
2 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
void ckadd(ll&a,ll b){a+=b;if(a>=mod)a%=mod;}
ll mul(ll a,ll b){return a*b%mod;}
void ckmul(ll&a,ll b){a=mul(a,b);}
ll powmod(ll x,ll k){ll ans=(ll)1;for(;k;k>>=1,ckmul(x,x))if(k&1)ckmul(ans,x);return ans;}
int n;
ll k;
int main(){
    scanf("%i %lld",&n,&k);
    long long ans=1;
    for(ll i=0;i<n;i++){
        if(k%2==0)ckadd(ans,powmod(2,n-i-1));
        //if(k%2==0)printf("%i %lld\n",i,powmod(2,n-i-1));
        k=(k+1)/2;
    }
    printf("%lld",ans);
    return 0;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |     scanf("%i %lld",&n,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 364 KB Output is correct