677A. Vanya and Fence

Problem Link


<Source Code>

#include<stdio.h>
#include<math.h>
#include<algorithm>

int main()

{
int i,t,n,tem,temp,sum;
scanf(“%d %d”,&n,&t);
int a[n];sum=0;
for(i=0;i<n;i++)
{scanf(“%d”,&a[i]);

}
std::sort(a,a+n);
for(i=0;i<n;i++){
tem=ceil((double)a[i]/(double)t);
tem=(int)tem;

sum+=tem;
}
printf(“%d\n”,sum);
}

Advertisements

1305- Area of a Parallelogram

Problem Link


<Source Code>

#include<stdio.h>
int main()
{
int ax,ay,bx,by,cx,cy,res,dx,dy,t,i;
scanf(“%d”,&t);
for(i=0;i<t;i++)
{res=0;
scanf(“%d %d %d %d %d %d”,&ax,&ay,&bx,&by,&cx,&cy);
dx=(ax+cx)-bx;
dy=(ay+cy)-by;
res=((ax*by+bx*cy+cx*dy+dx*ay))-((ay*bx+by*cx+cy*dx+dy*ax));
if(res<0)
res*=-1;
res=res*.5;
printf(“Case %d: %d %d %d\n”,i+1,dx,dy,res);

}
return 0;
}

339A:Helpful Maths

Problem Link

#include<stdio.h>
#include<algorithm>
int main()
{
char b[100],c[100];
int i,j;
gets(b);
j=0;
for(i=0;b[i]!=’\0′;i++){
if(b[i]==’1′ || b[i]==’2′ || b[i]==’3′){
c[j]=b[i];
j++;
}
}
c[j]=’\0′;
int d=j-1;
int k,l;

std::sort(c,c+j);
for(j=0;j<=d;j++){
if(j>0)
printf(“+”);
printf(“%c”,c[j]);
}
return 0;
}

681A:Good Contest

Problem Link

<Source Code>

#include<stdio.h>
#include<string.h>
struct nam
{
char name[1000];
int before;
int after;
};

int main()
{
int n,i,c=0,r=2400;scanf(“%d”,&n);
struct nam con[n];
getchar();
for(i=0;i<n;i++)
{scanf(“%s %d %d”,con[i].name,&con[i].before,&con[i].after);
}
for(i=0;i<n;i++)
{
if(con[i].before>=r && con[i].after>con[i].before)
{
c=1;
break;
}
}
if(c)
printf(“YES\n”);
else
printf(“NO\n”);
}

25B:Phone numbers

Problem Link

<Source Code>

#include<stdio.h>
int main()
{
long n,i;
scanf(“%ld”,&n);
char a[n];
getchar();
for( i=0; i<n; i++ )
{scanf(“%c”,&a[i]);
}
for( i=0; i<n; i++ )
{
putchar(a[i]);
if( i%2 && i<n-(n%2)-2 ) putchar(‘-‘);
}

}

25A:IQ TEST

Problem Link

<Source Code>

#include<stdio.h>
int main()
{
long long n,i,c=0,co=0,num;
scanf("%lld",&n);
long long a[n];
for(i=1;i<=n;i++)
{
scanf("%lld",&a[i]);
num=a[i];
if(num%2==0)
co++;
else
c++;
}

if(c>co)
{
for(i=1;i<=n;i++)
{
if(a[i]%2==0){
printf("%lld\n",i);
break;

}
}}
else
{
for(i=1;i<=n;i++)
{
if(a[i]%2==1){
printf("%lld\n",i);
break;

}
}

}}