1204A - BowWow and the Timetable - CodeForces Solution


math *1000

Please click on ads to support us..

Python Code:

s=input()
t=0
l=0
for i in range(len(s)-1,-1,-1):
    t+=int(s[i])*(2**l)
    l+=1
k=1
c=0
while(k<t):
    c+=1
    k*=4
print(c)

C++ Code:

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#include <iomanip>
#include <chrono>
using namespace std ;
#define ll long long

void FastInputOutput(){
    ios_base::sync_with_stdio( 0 );
    cin.tie(0);
    cout.tie(0);
}

inline int D(){
    int t;
    scanf("%d", &t);
    return t;
}
inline ll LLD(){
    ll t;
    scanf("%lld", &t);
    return t;
}
ll gcd(ll a, ll b){
    return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b){
    // gcd * lcm = a * b --> lcm = a / gcd * b;
    return a / gcd(a, b) * b;
}

long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}

int addmod(int a, int b, int m){
    return (((a % m) + (b % m) + m) % m);
}

const int N = 2e5 + 5, mod = 1e9 + 7;
char a[N];
void solve(){
    scanf("%s", a);
    int ans = (strlen(a) + 1) / 2;
    bool arrived = true;
    for(int i = 1; a[i]; ++i)
        arrived &= a[i] == '0';
    ans -= arrived && (strlen(a) & 1);
    printf("%d", ans);
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("//Users//amrsaud//Desktop//PS//in1", "r", stdin);
    //freopen("////Users//amrsaud//Desktop//PS//in1", "w", stdout);
#else
    // online submission
#endif
//    int t = D();
    int t = 1;
    while (t--) {
        solve();
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

263A - Beautiful Matrix
180C - Letter
151A - Soft Drinking
1352A - Sum of Round Numbers
281A - Word Capitalization
1646A - Square Counting
266A - Stones on the Table
61A - Ultra-Fast Mathematician
148A - Insomnia cure
1650A - Deletions of Two Adjacent Letters
1512A - Spy Detected
282A - Bit++
69A - Young Physicist
1651A - Playoff
734A - Anton and Danik
1300B - Assigning to Classes
1647A - Madoka and Math Dad
710A - King Moves
1131A - Sea Battle
118A - String Task
236A - Boy or Girl
271A - Beautiful Year
520B - Two Buttons
231A - Team
479C - Exams
1030A - In Search of an Easy Problem
158A - Next Round
71A - Way Too Long Words
160A - Twins
1A - Theatre Square