#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==============
#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==============
- #include <stdio.h>
- #include <ctype.h>
- int main()
- {
- int t,i;
- scanf("%d",&t);
- for(i=1;i<=t;i++)
- {
- int n,j,c=0;
- scanf("%d",&n);
- n++;
- char s[n];
- scanf("%s",s);
- for(j=0;s[j]!='\0';j++)
- {
- if(isdigit(s[j]) && !isdigit(s[j-1]))
- c++;
- }
- printf("%d\n",c);
- }
- return 0;
- }
No comments:
Post a Comment