結果

問題 No.910 素数部分列
ユーザー Naco
提出日時 2019-10-19 19:05:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 519 bytes
コンパイル時間 1,472 ms
コンパイル使用メモリ 167,696 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-27 15:04:24
合計ジャッジ時間 3,187 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 WA * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
    int N; cin >> N;
    string s; cin >> s;
    int ans=0;
    int j=0;
    for(int i=0;i<N;i++){
        if(s[i]=='3'||s[i]=='5'||s[i]=='7'){
            ans++;
        }else{
            if(j!=0){
                if(s[j]=='1'&&s[i]=='1') ans++;
                if(s[j]=='1'&&s[i]=='9') ans++;
                if(s[j]=='9'&&s[i]=='1') ans++;
                j=0;
            }else{
                j=i;
            }
        }
    }
    cout << ans << endl;
}
0