Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- string st;
- long long ind;
- char thru(long long ind) {
- //change to c++ method
- if(ind < st.size()){
- return st[ind];
- }
- int leng = st.size();
- while(2*leng <= ind){
- leng *= 2;
- }
- if (leng == ind){
- return thru(leng-1);
- }
- return thru(ind - leng - 1);
- }
- int main() {
- ifstream cin("cowcode.in");
- ofstream cout("cowcode.out");
- cin >> st >> ind;
- // call fucntion
- char ne = thru(ind-1);
- cout << ne << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement