#include <stdio.h> int main(void) { int n; scanf("%d", &n); int a[n]; int pos = 0; int sum = 0; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); sum += a[i]; if (a[i] != 0 && pos == 0) pos = i; } if (pos == 0) { printf("NO\n"); return 0; } printf("YES\n"); if (sum == 0) { printf("2\n"); printf("%d %d\n",1,pos); printf("%d %d\n",pos+1,n); } else { printf("1\n"); printf("%d %d\n",1,n); } return 0; }
#include<stdio.h> char field[4][4]; int dfs(int i,int j) { for (i = 0;i < 4;i++) { for (j = 0;j <= 1;j++) { if (field[i][j] == 'x' && field[i][j + 1] == 'x' && field[i][j + 2] == 'x') { return 1; } } } //每层进行查找 for (i = 0; i <= 1; i++) { for (j = 0;j < 4;j++) { if (field[i][j] == 'x' && field[i+1][j] == 'x' && field[i+2][j] == 'x') { return 1; } } } //每列进行查找 for (i = 0;i <= 1;i++) { for (j = 0;j <= 1;j++) { if (field[i][j] == 'x' && field[i + 1][j + 1] == 'x' && field[i + 2][j + 2] == 'x') { return 1; } } } //次对角线 for (i = 0;i <= 1;i++) { for (j = 2;j < 4;j++) { if (field[i][j] == 'x' && field[i + 1][j - 1] == 'x' && field[i + 2][j - 2] == 'x') { return 1; } } } //主对角线 return 0; } int main(void) { for (int i = 0;i < 4;i++) scanf("%s",field[i]); for (int i = 0;i < 4;i++) { for (int j = 0;j < 4;j++) { if (field[i][j] == '.') { field[i][j] = 'x'; if (dfs(i,j)) { printf("YES\n"); return 0; } field[i][j] = '.'; } } } printf("NO\n"); return 0; }
#include<stdio.h> int main(void) { int n; scanf("%d",&n); if(n%2==0) { printf("%d\n",n/2); for(int i = 0; i < n/2-1; i++) printf("%d ",2); printf("2\n"); } else { printf("%d\n",n/2); for(int i = 0; i < n/2-1; i++) printf("%d ",2); printf("3\n"); } return 0; }
#include<stdio.h> int main(void) { int a1,a2; int b1,b2; int c1,c2; scanf("%d%d",&a1,&a2); scanf("%d%d",&b1,&b2); scanf("%d%d",&c1,&c2); printf("%d\n",3); printf("%d %d\n",c1+b1-a1,c2+b2-a2); printf("%d %d\n",c1-b1+a1,c2-b2+a2); printf("%d %d\n",a1+b1-c1,a2+b2-c2); return 0; }
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。