Submission #1099200

#TimeUsernameProblemLanguageResultExecution timeMemory
1099200vjudge1Rack (eJOI19_rack)C++17
40 / 100
1 ms460 KiB
#include <algorithm> #include <iostream> #include <bits/stdc++.h> #include <cmath> #include <vector> using namespace std; const long long mod = 1e9+7; int binary_exponentiation(int number, int exponent) { int result; while (exponent > 0) { if(number & 1) result = result * number; exponent = exponent * exponent; number = number >> 1; } return result; } int make_path(long long seed, int length) { long long path = 0; for (int i = 0; i < length; i++) { if (((seed >> i) & 1) == 1) path = (path + binary_exponentiation(2, length - i - 1))%mod; } return path; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int height, node; cin >> height >> node; int rows = 1 << height; std::vector<int> path(height); for (int j = 0; j < height; ++j) { path[j] = ((node - 1) >> j) & 1; } long long int leaf = 1; long long int set = pow(2, height); for (int i : path) { set = set/2; if (i == 1) leaf += set; } cout << leaf%mod << endl; return 0; }

Compilation message (stderr)

rack.cpp: In function 'int main()':
rack.cpp:42:9: warning: unused variable 'rows' [-Wunused-variable]
   42 |     int rows = 1 << height;
      |         ^~~~
rack.cpp: In function 'int binary_exponentiation(int, int)':
rack.cpp:21:12: warning: 'result' may be used uninitialized in this function [-Wmaybe-uninitialized]
   21 |     return result;
      |            ^~~~~~
rack.cpp: In function 'int make_path(long long int, int)':
rack.cpp:29:73: warning: 'result' may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |         if (((seed >> i) & 1) == 1) path = (path + binary_exponentiation(2, length - i - 1))%mod;
      |                                                    ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...