2030
#define _CRT_SECURE_NO_WARNINGS 1
#include
#include
int main() {
int n;
char ch[1000];
int i = 0;
int t = 0;
while (scanf("%d", &n) != EOF) {
getchar();
for(int j=0;j<n;j++)
{
fgets(ch, 1000, stdin);
while (ch[i] != '\n') {
if (ch[i] >= 0 && ch[i] <= 127) {
t++;
}
i++;
}
printf("%d", (strlen(ch) - 1 - t) / 2);
t = 0;
i = 0;
}
}
}
#include
#include
int main()
{
char a[200];
int n, k, i, t;
scanf("%d", &n);
getchar();
while (n--)
{
t = 0;
gets(a);
k = strlen(a);
for (i = 0; i < k; i++)
if (a[i] < 0)
t++;
printf("%d\n", t / 2);
}
return 0;
}
2031
#define _CRT_SECURE_NO_WARNINGS 1
#include
#include
int main() {
int n, r;
int sum=0;
int t=0;
int N[100];
int flag;
while (scanf("%d %d", &n, &r) != EOF) {
if (n >= 0)
flag = 1;
else
flag = 0;
for (int i = 0; i < 20; i++) {
sum += (r - 1) * pow(r, i);
t++;
if (flag == 1) {
if (n <= sum)
break;
}
else
if (-n <= sum) {
n = -n;
break;
}
}
for (int i = 0; i < t; i++) {
N[i] = n % r;
n /=r;
}
for (int i = t - 1; i >= 0; i--) {
if (flag == 0)
{
printf("-");
flag = 1;
}
if (N[i] < 10)
printf("%d", N[i]);
else {
printf("%c", 'A' + N[i] - 10);
}
}
sum = 0;
t = 0;
}
}
2032
#define _CRT_SECURE_NO_WARNINGS 1
#include
#include
int main() {
int n;
int flag=-1;
int row[2][100];
int t=0,back;
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 100; j++) {
row[i][j] = 1;
}
}
while (scanf("%d", &n) != EOF) {
if (n == 1) {
printf("1\n");
continue;
}
printf("1\n");
for (int i = 2; i < n+1; i++) {
back = t;
t += (int)pow(flag, i);
for (int k = 1; k < i - 1; k++) {
row[t][k] = row[back][k - 1] + row[back][k];
}
for (int j = 0; j < i; j++) {
printf("%d ", row[t][j]);
}
printf("\n");
}
t = 0;
flag = -1;
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 100; j++) {
row[i][j] = 1;
}
}
}
}
2033
#define _CRT_SECURE_NO_WARNINGS 1
#include
int main() {
int n;
int time[6];
int T[3] = { 0 };
while (scanf("%d", &n) != EOF) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < 6; j++) {
scanf("%d", &time[j]);
}
T[2] = time[2] + time[5];
T[1] = time[1] + time[4];
T[0] = time[0] + time[3];
for (int k = 2; k > 0; k--) {
if (T[k] >= 60) {
T[k] = T[k] - 60;
T[k - 1]++;
}
}
for (int i = 0; i < 3; i++) {
printf("%d ", T[i]);
}
for (int i = 0; i < 3; i++) {
T[i] = 1;
}
}
}
}
2034
#define _CRT_SECURE_NO_WARNINGS 1
#include
int main() {
int n, m;
int N[100];
int M[100];
int member[100];
int num = 0;
int t = 0;
int flag = 0;
int min,mid;
while (scanf("%d %d", &n, &m) && (m != 0 || n != 0)) {
for (int i = 0; i < n; i++) {
scanf("%d", &N[i]);
}
for (int i = 0; i < m; i++) {
scanf("%d", &M[i]);
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if(M[j]==N[i]){
flag = 1;
break;
}
}
if (flag == 1)
{
flag = 0;
continue;
}
else
{
num++;
member[t] = i;
t++;
}
}
if (num == 0)
printf("NULL");
else
{
for (int i = 0; i < num; i++) {
min = N[member[i]];
for (int j = i + 1; j < num; j++) {
if (N[member[j]] < min) {
mid = min;
min = N[member[j]];
N[member[j]] = mid;
}
}
printf("%d ", min);
}
}
num = 0;
t = 0;
}
}
2035
#define _CRT_SECURE_NO_WARNINGS 1
#include
int main()
{
int a, b, t;
while (scanf("%d%d", &a, &b) && (a != 0 || b != 0)) {
t = a;
for (int i = 1; i < b; i++) {
a = a * t;
if (a > 1000)
a %= 1000;
}
printf("%d", a);
}
}
2036
#define _CRT_SECURE_NO_WARNINGS 1
#include
#include
double square(float x1, float y1, float x2, float y2, float x3, float y3);
int main() {
int n;
float N[1000][2];
double S=0;
while (scanf("%d", &n) && n != 0) {
for (int i = 0; i < n; i++) {
scanf("%f%f", &N[i][0], & N[i][1]);
}
for (int i = 1; i < n - 1; i++)
S += square(N[0][0], N[0][1], N[i][0], N[i][1], N[i + 1][0], N[i + 1][1]);
printf("%.1lf\n", S);
S = 0;
}
}
double square(float x1, float y1, float x2, float y2, float x3, float y3) {
double s;
s = 0.5 * ((x2 - x1) * (y3 - y1) - (y2 - y1)*(x3 - x1));
return s;
}
2037
#define _CRT_SECURE_NO_WARNINGS 1
#include
int timeSort(int* min, int n, int N[][2], int* t);
int main() {
int n;
int N[100][2];
int* min;
int flag=0;
int m = 0;
int* t = &m;
while (scanf("%d", &n) && n) {
for (int i = 0; i < n; i++) {
scanf("%d%d", &N[i][0], &N[i][1]);
}
min = &N[0][1];
for (int i = 1; i < n; i++) {
if (N[i][1] < *min) {
min = &N[i][1];
}
}
(*t)++;
while (flag != 1)
flag = timeSort(min,n,N,t);
printf("%d", *t);
flag = 0;
m = 0;
}
}
int timeSort(int* min, int n,int N[][2],int* t)
{
int M[100];
int num = 0;
for (int i = 0; i < n; i++) {
if (N[i][0] >= *min) {
M[num] = i;
num++;
}
}
if (num == 0) {
return 1;
}
int secMin = N[M[0]][1];
for (int i = 1; i < num; i++) {
if (N[M[i]][1] < secMin) {
secMin = N[M[i]][1];
}
}
(*t)++;
*min = secMin;
return 0;
}
2038
#define _CRT_SECURE_NO_WARNINGS 1
#include
int main() {
int M;
double a, b, c;
scanf("%d", &M);
for (int i = 0; i < M; i++) {
scanf("%lf%lf%lf", &a, &b, &c);
if (a + b > c && b + c > a && a + c > b) {
printf("YES");
}
else
printf("NO");
}
}
2040
#define _CRT_SECURE_NO_WARNINGS 1
#include
int sumDivide(int a);
int main() {
int M;
int a, b;
int flag = 0;
scanf("%d", &M);
for (int i = 0; i < M; i++) {
scanf("%d%d", &a, &b);
if (sumDivide(a) == b)
flag++;
if (sumDivide(b) == a)
flag++;
if (flag == 2)
printf("YES");
else
printf("NO");
flag = 0;
}
}
int sumDivide(int a) {
int sum=0;
for (int i = 1; i < a; i++) {
if (a % i == 0)
sum += i;
}
return sum;
}