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 1243. Divorce of the Seven Dwarfs

0.001s 227 КБ
Posted by Erzhan Shaniev 4 Mar 2008 13:10
var s1,s:string;
    i,k,x,code:integer;

begin
  read(s);
  i:=2; s1:=s[1]+s[2];
   repeat
    begin
     val(s1,k,code);
     x:=k mod 7;
     str(x,s1); inc(i); s1:=s1+s[i];
    end;
   until i>=length(s);
   if s1<>'' then
    begin
     val(s1,k,code);
     x:=k mod 7;
    end;
   write(x);
end.


very simple
Re: 0.001s 227 КБ
Posted by Alibek 4 Mar 2008 19:22
slish, hare vipendrivats9
Re: 0.001s 227 КБ
Posted by Zayakin Andrey[PermSU] 2 Dec 2009 22:00
#include <stdio.h>
#include <string.h>
const int d[6] = {1,3,2,6,4,5};
int main()
{
    char s[50];
    gets(s);
    int sum = 0, n = strlen(s);
    for (int i = n - 1; i >= 0; --i)
        sum += ( s[i] - '0' ) * d[(n-1-i)%6];
    printf("%d", sum%7);
}

Edited by author 02.12.2009 22:02