結果
| 問題 | 
                            No.1946 ロッカーの問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             沙耶花
                         | 
                    
| 提出日時 | 2022-05-20 21:39:24 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 247 ms / 3,000 ms | 
| コード長 | 526 bytes | 
| コンパイル時間 | 3,798 ms | 
| コンパイル使用メモリ | 250,144 KB | 
| 最終ジャッジ日時 | 2025-01-29 10:17:51 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000
int main() {
    
	int n,m;
	cin>>n>>m;
	
	vector<int> f(n+1,0);
	rep(i,m){
		
		int a;
		cin>>a;
		f[a] = 1;
	}
	
	int ans = 0;
	for(int i=n;i>=1;i--){
		if(f[i]==0)ans++;
		else{
			
			for(int j=1;j*j<=i;j++){
				if(i%j==0){
					f[j] ^= 1;
					if(j*j!=i)f[i/j]^=1;
				}
			}
			
		}
	}
	
	cout<<ans<<endl;
	
    return 0;
}
            
            
            
        
            
沙耶花