結果
| 問題 | No.826 連絡網 | 
| コンテスト | |
| ユーザー |  ngtkana | 
| 提出日時 | 2020-03-30 01:57:15 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 16 ms / 2,000 ms | 
| コード長 | 612 bytes | 
| コンパイル時間 | 2,091 ms | 
| コンパイル使用メモリ | 194,076 KB | 
| 最終ジャッジ日時 | 2025-01-09 10:57:08 | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 30 | 
ソースコード
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,p;std::cin>>n>>p;
    std::vector<lint>sieve(n+1);
    for(lint i=2;i*i<=n;i++){
        if(sieve.at(i))continue;
        for(lint j=i*i;j<=n;j+=i){
            sieve.at(j)=true;
        }
    }
    if(n<2*p&&!sieve.at(p)){
        std::cout<<1<<'\n';
        return 0;
    }
    lint ans=0;
    for(lint i=2;i<=n;i++){
        ans+=2*i<=n||sieve.at(i);
    }
    std::cout<<ans<<'\n';
}
            
            
            
        