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>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;
inline int mul(int x,int y){
return (x%mod)*(y%mod)%mod;
}
inline int add(int x,int y){
if(x+y>=mod)return x+y-mod;
return x+y;
}
inline int fp(int x,int y){
if(y==0)return 1;
if(y==1)return x;
int tt=fp(x,y/2);
tt=mul(tt,tt);
if(y%2==1)tt=mul(tt,x);
return tt;
}
main(void){
scanf("%lld %lld",&n,&m);
while(m>1){
//~ m--;
v.pb((m%2));
//~ if(m/2==0)break;
m=(m+1)/2;
}
int bas=1;
int say=n-1;
//~ reverse(v.begin(),v.end());
for(int i=0;i<(int)v.size();i++){
if(v[i]==0)bas=add(bas,fp(2,say));
say--;
//~ cout<<bas<<" "<<son<<endl;
}
printf("%lld\n",bas%mod);
return 0;
}
Compilation message (stderr)
rack.cpp:49:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(void){
^
rack.cpp: In function 'int main()':
rack.cpp:50:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld",&n,&m);
~~~~~^~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |