답안 #407214

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
407214 2021-05-18T16:14:38 Z luka1234 Rack (eJOI19_rack) C++14
40 / 100
1 ms 296 KB
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;  
ll p=1000000007;
ll logpow(ll v,ll e){
	if(e==0)
	   return 1;
	else{
		if(e%2==0){
			ll ans=logpow(v,e/2);
			ans%=p;
			ans=ans*ans;
			ans%=p;
			return ans;
		}
		else{
			ll ans=logpow(v,e/2);
			ans%=p;
			ans=ans*ans;
			ans%=p;
			ans*=v;
			ans%=p;
			return ans;
		}
	}
}
int main(){
    ll n,m;
    cin>>n>>m;
    ll v=1,cnt=0;
    while(cnt!=n){
    	if(m%2==1)
           v=2*v;
        else
           v=2*v+1;
        v%=p;
        if(m%2==0)
           m=m/2;
        else
           m=m/2+1;
        cnt++;
	}
	ll pow=logpow(2,n)-1;
	cout<<v-pow;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 292 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 292 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Incorrect 1 ms 204 KB Output isn't correct
15 Halted 0 ms 0 KB -