快来救我

P1218 [USACO1.5] 特殊的质数肋骨 Superprime Rib

可恶@刘锦钰你居然抄我代码AC了
by Vader10 @ 2018-11-24 10:05:00


# ~~《论·这题有什么可难的》~~ ```cpp #include<cstdio> #include<cstring> #include<iostream> using namespace std; int n; bool isPrime(int n) { if (n < 2) return false; for (int i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } void dfs(int step, int last) { if (last != 0 && !isPrime(last)) return ; if (step > n) { cout << last << endl; return ; } for (int i = 1; i <= 9; i++) { dfs(step + 1, last * 10 + i); } } int main() { cin >> n; dfs(1, 0); return 0; } ``` # 多简单啊
by pjz123 @ 2022-08-26 14:34:00


|