⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mipt018.cpp

📁 El Judge MIPT solutions to some easy problems, I hope be usefull to you...
💻 CPP
字号:
/*
Alfonso2 Peterssen
18 - 7 - 2008
MIPT #018 "What is the number?"
*/
#include <cstdio>

#define FOR( i, s, e ) \
    for ( int i = (s); i <= (e); i++ )

const int MAXN = 2000001;

int N, sol;
bool mark[MAXN];
int dp[MAXN];

int main() {

    scanf( "%d", &N );
    FOR( i, 2, N ) dp[i] = i;
    FOR( i, 2, N )
        if ( !mark[i] )
            for ( int j = i; j <= N; j += i ) {
                dp[j] = dp[j] / i * (i - 1);
                mark[j] = true;
            }

    FOR( i, 2, N )
        dp[i] += dp[i - 1];

    sol = ( N == 2 ) ? 0 : 32 - __builtin_clz( dp[N] - 1 );
    // 0 is undefined for __builtin_clz

    printf( "%d\n", sol );

    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -