|  | 
|  | 
| back to board | 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 !!! 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 !!! 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 !!! 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 !!! 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:44My 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 !!! superRe: AC in 6 line !!! #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 !!! Why does it work? I just don't understand the logic.Re: AC in 6 line !!! Posted by Daniil  1 Dec 2017 17:23AC 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 !!! Just 1 line :)
 print(int(input())%7)
 
 Edited by author 29.08.2018 01:51
 | 
 | 
|