, , . , x b- x=a0∙b0+a1∙b1++an∙bn, b ≥ 2 0 ≤ ai < b.
b- , b ≤ 36, b 0,1,, 9, A, B, , Z. , 0, 1, 2, - 0,1,, 9, A, B.
, S , , 36, , , .
:
s. , -1. , -2, . 0 ASCII, +1.
, , N , .. , .
#include <iostream>
using namespace std;
main()
{
int i,n,k;
n=4;
cin>>k;
int a[n];
if((k>=1000) && (k<=9999)) {
for(i=1;i<=4;i=i+1)
{
a[i]=k%10;
k= k/10.0;
}
if ((a[1]==a[4]) && (a[2]==a[3])) cout<<"YES";
else cout<<"NO";}
}
:
k. 1 4 , . , , Yes, No.
. , (, ).
#include <iostream>
using namespace std;
main()
{
int a,b,m,n;
char c[5];
cin>>c;
cin>>m>>n;
a=(int(c[0])-int('0'))*10+(int(c[1])-int('0'));
b=(int(c[3])-int('0'))*10+(int(c[4])-int('0'));
b+=n;
a=(a+m+b/60)%24;
b%=60;
if(a>=10) cout<<a; else cout<<"0"<<a;
cout<<":";
if(b>=10) cout<<b; else cout<<"0"<<b;
}
:
. m n . int , b int . b , a .
24 , . .
. . , .
|
|
. , . .
, , .
:
. , , - 202 (101 101 ) , 101-, , a[101] (a[h]) 1 (, ). 0 , , .. . , (h++; a[h]=1). , (h--; a[h]=1). , , , . 0 202 - . .
() - (-). - , N , T , P () S, N.
p P A > a, A (A N), a , . , S. , , , . , , .
. . , . , A > R , R A.
-. , .
:
, 1 n n . .
. , . . , 10000$ . , .
, , . , , . .
|
|
. , .
#include <iostream>
#include <iomanip>
using namespace std;
main()
{
int n,i;
double sum=0,a[30000];
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
for(i=1;i<n;i++)
{
sum+=(a[i-1]+a[i])/2;
}
cout<<fixed<<setprecision(10)<<sum/(n-1);
return 0;
}
:
n - . , , . . , .. . -. .
. . , - , , . . , , .
, , , , . a h, - 1 8. , , c6 e2.
: . k j . , , , .
. , . , . N .
, i- ai .
. . , , .
, , .
#include <iostream>
using namespace std;
int main()
{
int max,i,k=0,n;
unsigned int a[1001];
cin>>n;
for(i=1;i<=n;i++)
cin>>a[i];
a[n+1]=a[1];
a[n+2]=a[2];
max=a[1]+a[2]+a[3];
for(i=2;i<n+2;i++)
{k=a[i-1]+a[i]+a[i+1];
if((k)>max) max=k;
}
cout<<max;
}
:
. 1 n , , a[n+1]= a[1]; a[n+2]=a[2];. max . 2 n+2 , max. max.
. . 3 : a1 b1 , a2 b2 , a3 b3 .
|
|
K . , , . , W .
:
: - , . , - . , YES, NO.
, : , . . . K .
#include<iostream>
using namespace std;
int main()
{
int k;
char x,y,z;
x='G';
y='C';
z='V';
cin>>k;
for(int i=0; i<k; i++)
{
swap(z,y);
swap(x,y);
}
cout<<x<<y<<z;
}
:
- k. swap(z,y);
swap(x,y);. 0 k , . x,y,z.
. , , , . 8.00, 8.05. 20.00. , , . 10 . 8.00 , . , , .
#include <iostream>
using namespace std;
main()
{ int k;
cin>>k;
k=k*5-5;
if (k>720) cout<<"NO";
else cout<<k/60<<' '<<k%60;
}
:
- k. , k>720 No, .
- 2
, , . , , .
, . , , , .
, , .
#include <iostream>
#include <string>
using namespace std;
int main()
{
int n,i,k,j;
cin>>n;
int a[n+1];
for(i=1;i<=n;i++)
cin>>a[i];
cin>>k;
int b[k];
for(i=1;i<=k;i++)
cin>>b[i];
for(i=1;i<=n;i++)
for(j=1;j<=k;j++)
if(i==b[j]) a[i]--;
for(i=1;i<=n;i++)
if(a[i]>=0) cout<<"no"<<endl;
else cout<<"yes"<<endl;
}
:
- n. 1 n . - k. 1 k . i- , a[i]>=0 , .
|
|
, . , , , N . , , .
, .
#include <iostream>
using namespace std;
main()
{
int n;
cin>>n;
if(n<=1000) if (n==1) cout<<"0";
if((n<=1000)&&(n>1)) { if (n%2==0){
n=n/2;
cout<<n;
}
else cout<<n;}
}
:
- n. , 0. , , .
255- ( 1 ). , ( ), .
:
, 400
, 4, 100
:
year . , ( , 400, 4, 100). , 12.09, 13.09. - .
. . , x x, x ≥ 0 -x, x < 0.
:
- n. 0 n . 0 n .
, , .
. Mew Yorc Courier.
r1. , . r2, - r3. , ( , , , / ).
, , , , .
#include <iostream>
using namespace std;
main()
{
int r1,r2,r3;
cin>>r1>>r2>>r3;
if (r1>=(r2+r3)) cout<<"YES";else cout<<"NO";
}
:
. , YES, .. . NO.
- 3
. : .
#include <iostream>
using namespace std;
int main() {
int x, y, z;
cin >> x >> y >> z;
if (x + y > z && x + z > y && z + y > x) cout << "YES";
else cout << "NO";
}
:
. , . . , YES. NO.
ACM World Finals
, , , (http://acm.baylor.edu). 80 .
. , , .
|
|
. . . .
:
. , .
NEERC
NEERC (http://neerc.ifmo.ru) n . k , , . .
. . , , .
, , .
:
n , . 0 n a - . k - . 1 n : - - , ( - ) - , - .
- 2
. , N M . K . , , .
, , , .
:
- , . , . , . - , , , 0.
NM . A ( ) , B ( ) ; , .
B , , A . , B.
:
- n,m. 1 n n m. . , min, min.
. , . A1 , A2 , A3 . , : B1 , B2 , B3 . , . , , , , .
, , .
:
1 n max. max1. min min1. min(min1) max(max1), . , max*max1, min*min1, , .
, , , 1000 , , , 1024 .
, , , , , , 2K, K . . 2, 4, 8, 16, 32 .. , , . .
N. , .
#include <iostream>
using namespace std;
int main () {
int x = 1, n;
cin>> n;
while(n > x){
x*=2;
}
if(n == x){
cout<< "YES";
}else
cout<< "NO";
return 0;
}
:
- n. while n>x, x 2. n=x, YES, NO.
. , . : , . , , .
, , .
:
. a b i- . a- b- , . - . - , e=1, , YES. NO.
, . - , .
, , . , L , W H, 162, ? , , .
#include <iostream>
using namespace std;
main()
{
int l,w,h;
cin>>l>>w>>h;
if((l*h*2+h*w*2)%16==0) cout<<((l*h*2+h*w*2)/16);
else cout<<((l*h*2+h*w*2)/16+1);
}
:
, - l,w,h. 16, = l*h*2+h*w*2)/16, .
1
#include "stdafx.h"
#include <iostream>
#include <cmath>
using namespace std;
void main()
{ double h, b, n, a, i, x, j, d, p, max, y;
cout << "enter h, b, n:";
cin >> h >> b >> n;
for (i = 1; i <= 3; i++) {
cout << "enter a:";
cin >> a;
x = b + h;
y = 0.8 + 2 * sin(x) - 5.5 * sin(a)*sin(a);
d = fabs(y);
max = d;
p = d;
for (j = 2; j <= n; j++) {
x = b + j*h;
y = 0.8 + 2 * sin(x) - 5.5 * sin(a)*sin(a);
d = fabs(y);
p = p*d;
if (d > max) max = d;
}
cout << "p= " << p << " max= " << max << endl;
}system("pause");
}
2
3