Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shi4 #244

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Shi4 #244

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include<stdio.h>
int main()
{
int i,j,k;
int ar[12345];
int N,Q;
int a,b,c;
if(scanf("%d %d",&N,&Q)){};

for(a=0;a<N;a++)
{
if(scanf("%d",&ar[a])){};
}
for(b=0;b<Q;b++)
{
if(scanf("%d %d %d",&i,&j,&k)){};
for(c=i;c<=j;c++)

{
ar[c]=ar[c]+k;
}

}
for(a=0;a<N;a++)
printf("%d ",ar[a]);
return 0;
}



40 changes: 40 additions & 0 deletions i2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

#include<stdio.h>
long long int sum[1000001];
int main()
{
long long int pri[1000001];
long long int i,j,m,n;
long long int a;
int T;
for(i=0;i<1000001;i++)
{
pri[i]=1;
}
pri[0]=0;pri[1]=0;
for(i=2;i<1000001;i++)
{
if(pri[i]==1)
{
for(j=i;j*i<1000001;j++)
pri[i*j]=0;
}
}
for(i=2;i<1000001;i++)
{
if(pri[i]==1)
pri[i]=i;
}

for(i=0;i<1000001;i++)
sum[i]=sum[i-1]+pri[i];

if(scanf("%d",&T)){};
for(i=0;i<T;i++)
{
if(scanf("%lld %lld",&n,&m)){};
a=sum[m]-sum[n-1];
printf("%lld\n",a);
}
return 0;
}