#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#define BUG puts("here!!!");
using namespace std;
const int maxp = 2000, n = 10001;
int prime[maxp], total = 0;
bool isPrime(int k) {
for(int i = 0; i < total; i++) {
if(k % prime[i] == 0) {
return false;
}
}
return true;
}
int main() {
for(int i = 2; i <= n; i++) {
if(isPrime(i)) {
prime[total] = i;
total++;
}
}
int m;
while(cin >> m, m) {
int ans = 0;
for(int i = 0; m >= prime[i]; i++) {
int cnt = 0;
for(int j = i; j < total && cnt < m; j++) {
cnt += prime[j];
if(cnt == m) {
ans++;
}
}
}
cout << ans << endl;
}
return 0;
}
poj 2739 [离线预处理 + 枚举]
最新推荐文章于 2021-03-05 21:35:52 发布