結果

問題 No.910 素数部分列
ユーザー sigma425sigma425
提出日時 2019-10-18 21:35:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,417 bytes
コンパイル時間 2,028 ms
コンパイル使用メモリ 195,224 KB
最終ジャッジ日時 2025-01-07 22:42:31
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 WA * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;string s; cin >> N >> s;
	int res = 0;
	V<int> v;
	for(char c: s){
		int d = c-'0';
		if(d == 3 || d == 5 || d == 7) res++;
		else v.pb(d);
	}
	reverse(all(v));
	while((int)v.size() >= 2){
		int n = v.size();
		if(v[n-1] == 1){
			res++;
			v.pop_back();v.pop_back();
			continue;
		}
		if(n >= 3 && v[n-1] == 9 && v[n-2] == 9 && v[n-3] == 1){
			res++;
			rep(_,3) v.pop_back();
			continue;
		}
		v.pop_back();
	}
	cout << res << endl;
}
0