A – Hashmat the Brave Warrior
#include <stdio.h>
#include <stdlib.h>
int main()
{
   unsigned long long a,b;
   while(scanf("%llu%llu",&a,&b)!=EOF)
   {
       if(a>=b)
		   printf("%llu\n",a-b);
       else
		   printf("%llu\n",b-a);
   }
   return 0;
}
B – Back to High School Physics
#include <stdio.h>
int main()
{
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		    printf("%d\n",2*a*b);
	}
	return 0;
}
C – Ecological Premium
#include <stdio.h>
int main()
{
	int T,n,i,j,a,b,c,sum;
         scanf("%d",&T);
	for(i=0;i<T;i++)
	{
		scanf("%d",&n);
		sum=0;
		for(j=0;j<n;j++)
		{
			scanf("%d%d%d",&a,&b,&c);
                           sum+=a*c;
		}
		printf("%d\n",sum);
	}
	return 0;
}
D – The Decoder
#include <stdio.h>
#include <string.h>
int main()
{ 
	int n,i;
	char charater[1000]={''};
	while(scanf("%s",charater)!=EOF)
	{
		n=strlen(charater);
		for(i=0;i<n;i++)
			charater[i]-=7;
		puts(charater);
                  for(i=0;i<n;i++)
			charater[i]='';
	}
	return 0;
}
E – Kindergarten Counting Game
#include <stdio.h>
#include <string.h>
int main()
{
	int i,n,count;
	char c[1000]={''};
         while(fgets(c,1000, stdin))
	{   
		count=0;
		n=strlen(c);
		for(i=0;i<n;i++)
		{
                   if(((c[i]>='a'&&c[i]<='z')||(c[i]>='A'&&c[i]<='Z'))&&(c[i+1]<'A'
                   ||(c[i+1]>'Z'&&c[i+1]<'a')||c[i+1]>'z'))
		 {
                    count++;
		 }
		}
		printf("%d\n",count);
		memset(c,0,sizeof(char)*1000);
		count=0;
	}
	return 0;
}
F – Machined Surfaces
#include<stdio.h>
#include<string.h>
int main()
{
 char arr[25][25];
 int i,j,arr2[25],max,sum;
 unsigned int N;
 while(scanf("%d",&N)==1,N) {

  memset(arr2,0,sizeof(arr2));
  sum=0;
  for(i=0;i<N;i++) {
   for(j=0;j<25;j++)
      scanf("%c",&arr[i][j]);
      getchar();
  }
  for(i=0;i<N;i++)
   for(j=0;j<25;j++)
    if(arr[i][j]=='X')
       arr2[i]++;

   max=arr2[0];
   for(i=0;i<N;i++)
    if(arr2[i]>max)
       max=arr2[i];

  for(i=0;i<N;i++)
   sum+=(max-arr2[i]);
  printf("%d\n",sum);
 }
 return 0;
}

发表评论

电子邮件地址不会被公开。

Post Navigation