.


:




:

































 

 

 

 


H: . .

.

.

, .

1 - , 2 - , 0 - .

1 1 0

 

-3 10 2

 

L = input().split()
a = int(L[0])
b = int(L[1])
if(a>b):
print('1')
elif(b>a):
print('2')
else:
print('0')

#include <iostream>

using namespace std;
int main()
{
int a, b;
cin >> a >> b;
if (a>b) {
cout << 1;
return 0;}
if (a<b) {
cout << 2;
return 0;}
cout << 0;
return 0;
}

B: .

, . ( , 4, 100, 400).

N - (0 < N < 100000).

YES NO .

1 NO

 

2000 YES

N = int(input()); answer = 'NO'
if (N%4==0)and(N%100!=0):
answer = 'YES'
if (N%400==0):
answer = 'YES'
print(answer)

#include <iostream>
#include <string>
using namespace std;
int main()
{
int N;
string answer = "NO";
cin >> N;
if ((N%4==0)&&(N%100!=0)) answer = "YES";
if (N%400==0) answer = "YES";
cout << answer;
return 0;
}

C: .

N , N, .

! .

N, 10000.

. .

50 1 4 9 16 25 36 49

 

16 1 4 9 16

 

N = int(input()); p = 1; b = 1;
while (b<N):
print(b,end=' ')
p+=1; b = b + 2*p 1

#include <iostream>
using namespace std;
int main()
{
int N;
cin >> N;
int p = 1;
int b = 1;
while (b<N){
p++;
cout << b << " ";
b=b+2*p-1;
}
return 0;
}

D: .

N. YES, N , NO .

! . pow. if .

N, 10000.

YES , NO.

8 YES

 

3 NO

 

N = int(input()); answer = 'YES'
while(N>2):
if (N%2==1):
answer='NO'
N = N/2
print(answer)

#include <iostream>
#include <string>
using namespace std;
int main()
{
int N;
string answer = "YES";
cin >> N;
while (N>2) {
if (N%2==1) answer="NO";
N = N/2;
}
cout << answer;
return 0;

E: .

, .

, .

- .

30 18 6

 

1071 462 21

a, b = int(input()), int(input())
while (a!=b):
if (a>b):
a=a-b
else:
b=b-a
print(a)

#include <iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
while (a!=b){
if (a>b) a = a - b;
else b = b - a;
}
cout << a;
return 0;
}

F: .

, .

.

1 - , 0 - .

997 1

 

5083 0

 

N = int(input()); answer = 1; q = 2

t = N**0.5
while(q<t):
if (N%q==0):
answer=0
q+=1
print(answer)

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int N;
cin >> N;
int ans = 1;
int q = 2;
int root = sqrt(N);
while (q<=root){
if (N%q==0) ans = 0;
q++;
};
cout << ans;
return 0;
}

G: .

0. . , , .

, 0 ( 0 ). .

, , - 0.

1 2 4 7 4 0 4
1 3 5 0 0


N = 1; max = 0
while (N > 0):
N = int(input())
if (N%2==0):
if (max<N):
max = N
print(max)

#include <iostream>
using namespace std;
int main()
{
int max, N;
max = 0;
N = 1;
while (N!=0){
cin >> N;
if ((max<N)and(N%2==0)) max = N;
}
cout << max;
return 0;
}

H: . .

. , . , .

N, , N -- . 0 100. .

, .

4 5 5 2 5 5

N = int(input());L = [0]*100; ans = 0;max = 0
for k in range(N):
M = int(input());L[M]+=1
for k in range(100):
if (max<L[k]):
max = L[k];ans = k
print(ans)

#include <iostream>
using namespace std;
int main()
{
int max, N, ans, x;int a[100]={ };

max = 0; ans = 0;cin >> N;
for (int k = 0; k<N; k++){
cin >> x; a[x]++;
}
for (int k = 0; k<100; k++){
if (max<a[k]) {
max = a[k]; ans = k;
}
}
cout << ans;
return 0;
}

I: .

, , 1- n. . 1 , , . ?

- n < 10^4 - n . , n .

- 937.

21 1 1
32 2 1 2


N = int(input()); L = input().split(); M = [0]*N
M[N-1]=1; M[N-2]=1
for k in range(N-3,-1,-1):
p = int(L[k])
if ((k+p)<N)and(p!=1):
M[k]=M[k+1]+M[k+p]
else:
M[k]=M[k+1]
print(M[0]%937)

#include <iostream>
using namespace std;
int main()
{
int N, x; cin >> N;
int a[10000]={ }; int schetchik[10000]={ };
schetchik[N-1]=1; schetchik[N-2]=1;
for (int k = 0; k<N; k++){
cin >> x; a[k]=x;
}
for (int k = N-3; k>=0; k--){
if ((k+a[k]<N)&&(a[k]!=1)) {
schetchik[k]=(schetchik[k+1]+schetchik[k+a[k]])%937;
} else schetchik[k] = schetchik[k+1];
}
cout << schetchik[0]%937;
return 0;
}



<== | ==>
| 3
:


: 2018-10-14; !; : 753 |


:

:

- , .
==> ...

1656 - | 1483 -


© 2015-2024 lektsii.org - -

: 0.055 .