Skip to main content

solution of VENOM - Touch of Venom on spoj

VENOM - Touch of Venom

#include<stdio.h>
int main()
{
long long int t,h,p,k,a,count,i;
scanf("%lld",&t);
while(t--)
{ i=1,count=0;
scanf("%lld%lld%lld",&h,&p,&a);
while(h!=0)
{
k=i*p;
i++;
h=h-k;
count++;
if(h>0)
{
h=h+a;
count++;
}
else
break;
}
printf("%lld\n",count);
}
}

Comments

Popular posts from this blog

solution of TRICOUNT - Counting Triangles on spoj

  TRICOUNT - Counting Triangles solution- #include<stdio.h> int main() {     int t;     scanf("%d",&t);     while(t--)     {         long long unsigned num,sum;         scanf("%llu",&num);         if(num%2==0)         sum=(num*(num+2)*((2*num)+1))/8;         else         sum=((num*(num+2)*((2*num)+1))-1)/8;         printf("%llu\n",sum);     }     return 0; }

solution of PRIME1 - Prime Generator on spoj

PRIME1 - Prime Generator solution- #include<stdio.h> #include<math.h> int main() {int t; long long int l,h,i,flag; scanf("%d",&t); while(t--) { scanf("%lld%lld",&l,&h); while(l<=h) { flag=0; for(i=2;i<=sqrt(l);i++) { if(l%i==0) { flag=1;     break; } } if(flag==0) { if(l!=1) printf("%lld\n",l); } l++; } printf("\n"); } return 0; }