Sort by

recency

|

1009 Discussions

|

  • + 0 comments
    long strangeCounter(long t) {
        long sum = 3;
        while(sum < t) {
            sum += sum + 3;
        }
        long diff = (sum + 1 - t);
        return diff;   
    }
    
  • + 0 comments

    include

    using namespace std;

    long strangeCounter(long t) { long cycle_start = 1; long cycle_length = 3;

    while (cycle_start + cycle_length <= t) {
        cycle_start += cycle_length;
        cycle_length *= 2;
    }
    
    return cycle_length - (t - cycle_start);
    

    }

    int main() { ios::sync_with_stdio(false); cin.tie(NULL);

    long t; cin >> t;
    cout << strangeCounter(t) << "\n";
    
    return 0;
    

    }

  • + 0 comments

    include

    using namespace std;

    long strangeCounter(long t) { long cycle_start = 1; long cycle_length = 3;

    while (cycle_start + cycle_length <= t) {
        cycle_start += cycle_length;
        cycle_length *= 2;
    }
    
    return cycle_length - (t - cycle_start);
    

    }

    int main() { ios::sync_with_stdio(false); cin.tie(NULL);

    long t; cin >> t;
    cout << strangeCounter(t) << "\n";
    
    return 0;
    

    }

  • + 0 comments

    import java.io.*;

    class Result {

    public static long strangeCounter(long t) {
        long cycleStart = 1;
        long cycleValue = 3;
    
        while (t > cycleStart + cycleValue - 1) {
            cycleStart += cycleValue;
            cycleValue *= 2;
        }
    
        return cycleValue - (t - cycleStart);
    }
    

    }

    public class Solution { public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));

        long t = Long.parseLong(bufferedReader.readLine().trim());
    
        long result = Result.strangeCounter(t);
    
        bufferedWriter.write(String.valueOf(result));
        bufferedWriter.newLine();
    
        bufferedReader.close();
        bufferedWriter.close();
    }
    

    }

  • + 0 comments
    def strangeCounter(t):
        m=1
        i=1
        n=0
        while m<=t:
            m=3*i
            if t>n and t<=m:
                return ((m+1)-t)
            i+=i+1
            n=m