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

AC in 6 line !!!
Posted by hoan 19 Nov 2010 09:37
#include <cstdio>
char ch, res;
int main (){
    while(scanf(" %c", &ch)!= EOF||(printf("%d\n", res)&0))
        res= (res*10+ ch-'0')%7;
}
Re: AC in 6 line !!!
Posted by Enigma [UB of TUIT] 19 Nov 2010 11:20
I'm too!!!
import java.math.BigInteger;
import java.util.Scanner;
public class T_1243 {
    public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          BigInteger n = sc.nextBigInteger();
          System.out.print(n.mod(new BigInteger("7"); )); }}
Re: AC in 6 line !!!
Posted by Moonstone [Samara SAU] 19 Nov 2010 23:29
public class Timus_1243 {
    public static void main(String[] args) {
        System.out.print(new java.util.Scanner(System.in).nextBigInteger().mod(java.math.BigInteger.valueOf(7)));
    }
}
Re: AC in 6 line !!!
Posted by waterlink 17 Dec 2010 01:14
you used long arithmetic, it is not best solution, read first post more accurately, it doesn't using any long arythmetic and arrays, collections, etc.
Re: AC in 6 line !!!
Posted by Andrew Suhani 25 Mar 2011 22:51
I used the same algoritm! But on Pascal it takes a litle more lines(11 to be exact).

But on Pascal my program works 0.015 seconds, but yours on C - 0.031

Edited by author 25.03.2011 22:55
Re: AC in 6 line !!!
Posted by S.77 2 Aug 2011 03:44
My C solution works the same time as yours, but it used 104 КB memory instead of 154 КB in your case.

#include <stdio.h>
int main(void){
    int c,a=0;
    for(;(c=getchar())!='\n';a=(a*10+c-'0')%7);
    printf("%u\n",a);
    return 0;
}
Re: AC in 6 line !!!
Posted by Mirahmad Ravilov 13 Dec 2011 20:32
super
Re: AC in 6 line !!!
Posted by saba_tavdgiridze 6 Jan 2013 18:39
#include <iostream>
int main(void){
    int c,a=0;
    for(;(c=getchar())!='\n';a=(a*10+c-'0')%7);
    printf("%u\n",a);
    return 0;
}
0.015s.
Re: AC in 6 line !!!
Posted by GastonFontenla 9 Aug 2015 03:51
Why does it work? I just don't understand the logic.
Re: AC in 6 line !!!
Posted by Daniil 1 Dec 2017 17:23
AC in 2 lines:

n = int(input())
print(n%7)
Re: AC in 6 line !!!
Posted by Death 29 Jul 2018 19:36
+
Re: AC in 6 line !!!
Posted by Darkness 29 Aug 2018 01:51
Just 1 line :)

print(int(input())%7)

Edited by author 29.08.2018 01:51