ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1000. A+B Problem

No subject
Posted by Rasul 19 Oct 2012 16:51
#include<iostream>
#include<string>
using namespace std;
int n,sum[999],l=0;
char a[101],b[101];
int main(){
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>a[i]>>b[i];

    for(int i=0;i<n;i++){
    if(a[i]=='a')
    a[i]='1';
    if(a[i]=='b')
    a[i]='2';
    if(a[i]=='c')
    a[i]='3';
    if(a[i]=='d')
    a[i]='4';
    if(a[i]=='e')
    a[i]='5';
    if(a[i]=='f')
    a[i]='6';
    if(a[i]=='g')
    a[i]='7';
    if(a[i]=='h')
    a[i]='8';
    }
    for(int i=0;i<n;i++){
        if(a[i]-48+2<=8&&a[i]-48+2>0&&b[i]-48+1<=8&&b[i]-48+1>0)
            sum[i]=sum[i]+1;
        if(a[i]-48+1<=8&&a[i]-48+1>0&&b[i]-48+2<=8&&b[i]-48+2>0)
            sum[i]=sum[i]+1;
        if(a[i]-48-1<=8&&a[i]-48-1>0&&b[i]-48+2<=8&&b[i]-48+2>0)
            sum[i]=sum[i]+1;
        if(a[i]-48-2<=8&&a[i]-48-2>0&&b[i]-48+1<=8&&b[i]-48+1>0)
            sum[i]=sum[i]+1;
        if(a[i]-48-2<=8&&a[i]-48-2>0&&b[i]-48-1<=8&&b[i]-48-1>0)
            sum[i]=sum[i]+1;
        if(a[i]-48-1<=8&&a[i]-48-1>0&&b[i]-48-2<=8&&b[i]-48-2>0)
            sum[i]=sum[i]+1;
        if(a[i]-48+1<=8&&a[i]-48+1>0&&b[i]-48-2<=8&&b[i]-48-2>0)
            sum[i]=sum[i]+1;
        if(a[i]-48+2<=8&&a[i]-48+2>0&&b[i]-48-1<=8&&b[i]-48-1>0)
            sum[i]=sum[i]+1;
        }
        for(int i=0;i<n;i++)
        cout<<sum[i]<<endl;
}
Re: No subject
Posted by Salimov Albert 2 Dec 2012 22:36
Подсказка
Используйте +
var n,i,j,k:integer;s:real;a:array[1..20,1..20] of real;zer:boolean;
label 1;
begin
s:=1;
readln(n);
for i:=1 to n do
for j:=1 to n do
read(a[i,j]);
for k:=1 to n-1 do
if a[k,k]=0 then begin zer:=true;goto 1; end else
for i:=k+1 to n do
for j:=k+1 to n do
a[i,j]:=a[i,j]-a[i,k]*a[k,j]/a[k,k];
for k:=1 to n do
s:=s*a[k,k];
writeln(s:0:0);
1:if zer then writeln('0');
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j],' ');
writeln;
end;
end.
Re: No subject
Posted by Salimov Albert 3 Dec 2012 20:28
var a:array[1..100,1..100] of integer;k,n,m,max,x,y,i,j:integer;
begin
readln(n,m);
readln(x,y);
for i:=1 to n do
for j:=1 to n do
a[i,j]:=abs(i-x)+abs(j-y);
for k:=1 to m-1 do
begin
readln(x,y);
for i:=1 to n do
for j:=1 to n do
if a[i,j]>abs(i-x)+abs(j-y) then a[i,j]:=abs(i-x)+abs(j-y);
end;
for i:=1 to n do
for j:=1 to n do
if a[i,j]>max then max:=a[i,j];
writeln(max);
end.
Re: No subject
Posted by Salimov Albert 18 Dec 2012 00:25
var ab,bc,ac,ad,bd,cd:real;
a1,a2,a3,a4,b1,b2,b3,b4:real;
s,s1,s2,s3:real;
function stor(x,y,z,t:real):real;
begin
stor:=sqrt((sqr(x-y))+(sqr(z-t)));
end;
function square(n,k,v:real):real;
var m:real;
begin
m:=(n+k+v)/2;
square:=trunc(sqrt(m*(m-n)*(m-v)*(m-k))*10);
end;
begin
{repeat}
writeln ('Введите координату вершины A');
readln (a1,b1);
writeln ('Введите координату вершины B');
readln (a2,b2);
writeln ('Введите координату вершины C');
readln (a3,b3);
writeln ('Введите координаты точки D');
readln(a4,b4);
AB:=stor(a1,a2,b1,b2);
BC:=stor(a2,a3,b2,b3);
AC:=stor(a1,a3,b1,b3);
ad:=stor(a1,a4,b1,b4);
bd:=stor(a2,a4,b2,b4);
cd:=stor(a3,a4,b3,b4);
{if(AB>=BC+AC)or(AC>=AB+BC)or(BC>=AB+AC) then writeln('Это не треугольник, введите данные заново');
until (AB<BC+AC)and(AC<AB+BC)and(BC<AB+AC);}
s:=square(ab,bc,ac);
s1:=square(ab,bd,ad);
s2:=square(bd,cd,bc);
s3:=square(cd,ad,ac);
{writeln(s,' ',s1,' ',s2,' ',s3);}
if abs(s-s1-s2-s3)<5 then writeln ('точка D является внутренней точкой треугольника ABC') else
writeln ('точка D не является внутренней точкой треугольника ABC');
{writeln(abs(s-s1-s2-s3));}
end.