Friday 23 August 2019

Find Product Hacker Earth Solution in C,Let Us Understand Computer Hacker Earth Solution in C,Count Numbers Hacker Earth Solution in C

#include <stdio.h>
#define ma 1000000007
int main(){
int num,i,a;
unsigned long long int ans=1;
scanf("%d", &num);

for(i=0;i<num;i++){
   scanf("%d", &a);
   ans=(ans*a)%ma;
}
printf("%d", ans);

}

===============or=================
#include <stdio.h>
const int ma = 1e9+7;
int main(){
int num,i,a;
unsigned long long int ans=1;
scanf("%d", &num);

for(i=0;i<num;i++){
   scanf("%d", &a);
   ans=(ans*a)%ma;
}
printf("%d", ans);

}

=============================================================
Let Us Understand Computer Hacker Earth Solution in C

#include <stdio.h>
#include <math.h>
int main()
{
unsigned long long int t;
scanf("%llu",&t);
while(t--)
{
unsigned long long int k,n,ans,i;
scanf("%lld",&n);
i=1;
while(i<=sqrt(n))
{
i=i*2;
}
if(n/i>=i/2)
ans=n-n/i;
else
ans=(n-(i/2))+1;
  printf("%lld\n",ans);
}
}

===========Count Numbers Hacker Earth Solution in C==============
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. int main()
  4. {
  5. int t,i;
  6. scanf("%d",&t);
  7. for(i=1;i<=t;i++)
  8. {
  9. int n,j,c=0;
  10. scanf("%d",&n);
  11. n++;
  12. char s[n];
  13. scanf("%s",s);
  14. for(j=0;s[j]!='\0';j++)
  15. {
  16. if(isdigit(s[j]) && !isdigit(s[j-1]))
  17. c++;
  18. }
  19. printf("%d\n",c);
  20. }
  21. return 0;
  22. }

No comments:

Post a Comment