Submission #491808

# Submission time Handle Problem Language Result Execution time Memory
491808 2021-12-04T14:15:04 Z uncripted Rack (eJOI19_rack) C++11
100 / 100
9 ms 8140 KB
#include<bits/stdc++.h>
using namespace std;
long long const m=1000000007;	
long long a[1000005];
long long p2[1000001];
int main(){
	long long n,k;
	cin>>n>>k;

	long long k1=k;
	long long ii=1;

	k1--;
	p2[0]=1;
	for(long long i=1; i<=1000001; i++){
		p2[i]=(p2[i-1]*2)%m;
	}
	while(k1>0){
		a[ii]=k1%2;
		k1=k1/2;
		ii++;
		//cout<<k1<<"l"<<endl;
	}
	ii=n;
	long long sum=0;
	for(long long i=ii; i>=1; i--){
		if(a[i]==1){
			sum+=(p2[ii-i]);
			sum=sum%m;
		}
	}
	
	cout<<(sum+1)%m;
 	
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:16:8: warning: iteration 1000000 invokes undefined behavior [-Waggressive-loop-optimizations]
   16 |   p2[i]=(p2[i-1]*2)%m;
      |   ~~~~~^~~~~~~~~~~~~~
rack.cpp:15:22: note: within this loop
   15 |  for(long long i=1; i<=1000001; i++){
      |                     ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8012 KB Output is correct
2 Correct 8 ms 8012 KB Output is correct
3 Correct 7 ms 8108 KB Output is correct
4 Correct 7 ms 8096 KB Output is correct
5 Correct 7 ms 8012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8012 KB Output is correct
2 Correct 8 ms 8012 KB Output is correct
3 Correct 7 ms 8108 KB Output is correct
4 Correct 7 ms 8096 KB Output is correct
5 Correct 7 ms 8012 KB Output is correct
6 Correct 7 ms 8012 KB Output is correct
7 Correct 8 ms 8028 KB Output is correct
8 Correct 7 ms 8012 KB Output is correct
9 Correct 8 ms 8012 KB Output is correct
10 Correct 8 ms 8012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8012 KB Output is correct
2 Correct 8 ms 8012 KB Output is correct
3 Correct 7 ms 8108 KB Output is correct
4 Correct 7 ms 8096 KB Output is correct
5 Correct 7 ms 8012 KB Output is correct
6 Correct 7 ms 8012 KB Output is correct
7 Correct 8 ms 8028 KB Output is correct
8 Correct 7 ms 8012 KB Output is correct
9 Correct 8 ms 8012 KB Output is correct
10 Correct 8 ms 8012 KB Output is correct
11 Correct 9 ms 8004 KB Output is correct
12 Correct 7 ms 8064 KB Output is correct
13 Correct 8 ms 8048 KB Output is correct
14 Correct 7 ms 8008 KB Output is correct
15 Correct 9 ms 8140 KB Output is correct