Skip to content

Commit

Permalink
solve 2581
Browse files Browse the repository at this point in the history
  • Loading branch information
younghyunshin committed Mar 31, 2019
1 parent a7c2e6c commit 5c8fa4a
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions problems/2581/21900398.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include<stdio.h>
#include<string.h>
int main()
{
char arr[100] = { 0 };
int t = 0;
int m, n;
scanf("%d\n%d", &m, &n);
int i;
int a;
int flag = 0;
for (i = m; i <= n; i++)
{
for (a = 2; a < i; a++)
{
if (i%a == 0)
{
flag = 0;
break;
}
else
{
flag = 1;

}
}
if (flag == 1)
{
arr[t] = i;
t++;
}
}
int len = strlen(arr);
if (len == 0)
{
printf("-1");
return 0;
}
int sum = 0;
int x;

for (x = 0; x < len; x++)
{
sum += arr[x];
}

printf("%d %d", sum, arr[0]);
return 0;

}

0 comments on commit 5c8fa4a

Please sign in to comment.