cf 359A 359B

it2022-05-08  11

359A 如果有点在边上则最少两次 没有则最少操作4次

#include <cstdio> #include <cstring> #include <algorithm> #include <cstdlib> using namespace std; int g[50][50],n,m; int main() { bool flag = false; scanf("%d%d",&n,&m); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) { scanf("%d",&g[i][j]); if(g[i][j] && (i == 0 || j == 0 || i == n-1 || j == m-1)) flag = true; } if(flag) puts("2"); else puts("4"); return 0; } 359B 如果是一个递增的数列答案是零  只需要将数字k+1移动到数列的第一个位置 就可以满足题目条件

#include <cstdio> #include <cstring> #include <algorithm> #include <cstdlib> using namespace std; int main() { int n,k,flag; scanf("%d%d",&n,&k); flag = 1+k; printf("%d",flag); for(int i = 1; i <= 2*n; i++) { if(i == flag) continue; printf(" %d",i); } return 0; }

转载于:https://www.cnblogs.com/avema/p/3774274.html


最新回复(0)