-
Notifications
You must be signed in to change notification settings - Fork 0
/
2007var1taskB.cpp
53 lines (46 loc) · 923 Bytes
/
2007var1taskB.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//var 1 task B
#include <stdio.h>
#include <math.h>
int free_from_sqr (int a);
int input(const char name[], int* val);
int main()
{
int N;
if (!input("N", &N))
{
printf("input error\n");
return (0);
}
else
{
if (free_from_sqr(N))
printf("There are full squares in decomposition of %d", N);
else printf("There are no full squares in decomposition of %d", N);
return (0);
}
}
int input(const char name[], int* val)
{
printf("enter %s> ", name);
if (!scanf("%d", val)) return 0;
else return 1;
}
int free_from_sqr (int a)
{
int marker = 0, mem = 0, i = 2;
while (i<=(int)(sqrt(a)+1))
{
if (a%i==0)
{
if (mem==i)
{
marker = 1;
break;
}
mem = i;
a=a/i;
}
else i++;
}
return(marker);
}