結果
問題 | No.1946 ロッカーの問題 |
ユーザー |
|
提出日時 | 2022-05-21 01:47:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 241 ms / 3,000 ms |
コード長 | 480 bytes |
コンパイル時間 | 1,430 ms |
コンパイル使用メモリ | 168,280 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-20 10:58:19 |
合計ジャッジ時間 | 3,095 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,M; cin>>N>>M; vector<bool>op(N); for(int i=0,t;i<M;i++){ cin>>t; op[t-1]=true; } int ans=0; for(int i=N;i>0;--i){ if(!op[i-1]){ ans+=1; continue; } for(int j=1;j*j<=i;j++){ if(i%j==0){ op[j-1]=1-op[j-1]; if(i/j!=j){ op[i/j-1]=1-op[i/j-1]; } } } } cout<<ans<<'\n'; }