Show all threads Hide all threads Show all messages Hide all messages |
Python 3 | tdnnojtupbkmuhehvb | 1243. Divorce of the Seven Dwarfs | 24 Aug 2021 11:19 | 2 |
Python 3 tdnnojtupbkmuhehvb 12 Apr 2021 14:40 |
be careful about "%" | Vlad | 1243. Divorce of the Seven Dwarfs | 29 Jun 2021 11:47 | 2 |
in python: -5 % 7 == 2 in c++: -5 % 7 == -5 |
AC one LINE | matvey22122 | 1243. Divorce of the Seven Dwarfs | 7 May 2020 20:05 | 1 |
|
So easy / phyton 3 solution | SMMaster | 1243. Divorce of the Seven Dwarfs | 15 Dec 2019 16:37 | 1 |
a = int(input()) c= a//7 d=c*7 print(a-d) |
Logic Explanation | Evans_DoN | 1243. Divorce of the Seven Dwarfs | 3 Nov 2019 18:18 | 1 |
I got my code running due to the solutions posted.. But i want to understand the logic behind the division.. Any one? |
WA test 5 please help me c++ | Abdullahil Baki Adol | 1243. Divorce of the Seven Dwarfs | 6 Aug 2019 22:37 | 1 |
#include<bits/stdc++.h> using namespace std; int main(){ unsigned long long int n; try{ cin >> n; cout << n%7 << endl; }catch(exception e){ cout << 1 << endl; } return 0; } |
5 test? c | Sanchir | 1243. Divorce of the Seven Dwarfs | 23 Feb 2019 17:10 | 1 |
#include <stdio.h> int main() { unsigned long long int a; scanf("%llu", &a); if (a/7!=0) printf("%llu\n", a%7); else if (a < 7) printf("%d\n", a); } |
признак делимости на 7 ;) | Mapu | 1243. Divorce of the Seven Dwarfs | 25 Jan 2019 02:16 | 1 |
|
AC in 6 line !!! | hoan | 1243. Divorce of the Seven Dwarfs | 29 Aug 2018 01:51 | 12 |
#include <cstdio> char ch, res; int main (){ while(scanf(" %c", &ch)!= EOF||(printf("%d\n", res)&0)) res= (res*10+ ch-'0')%7; } 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"); )); }} 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))); } } 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. 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 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; } #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. Why does it work? I just don't understand the logic. AC in 2 lines: n = int(input()) print(n%7) Just 1 line :) print(int(input())%7) Edited by author 29.08.2018 01:51 |
Accepted (Visual C++) | Vensus | 1243. Divorce of the Seven Dwarfs | 2 Nov 2015 00:01 | 3 |
#include <iostream> using namespace std; int main() { int k = 0; long long int s = 0; char num[52]; int arr[51]; bool flag = true; cin >> num; for(int i = 0; flag; i++) { switch(num[i]) { case '0': { arr[i] = 0; k++; break; } case '1': { arr[i] = 1; k++; break; } case '2': { arr[i] = 2; k++; break; } case '3': { arr[i] = 3; k++; break; } case '4': { arr[i] = 4; k++; break; } case '5': { arr[i] = 5; k++; break; } case '6': { arr[i] = 6; k++; break; } case '7': { arr[i] = 7; k++; break; } case '8': { arr[i] = 8; k++; break; } case '9': { arr[i] = 9; k++; break; } case '\0': { flag = false; break; } } } for(int i = k-1; i+1 > 6;) { s = s + arr[i]; s = s + arr[i-1]*3; s = s + arr[i-2]*2; s = s + arr[i-3]*6; s = s + arr[i-4]*4; s = s + arr[i-5]*5; i = i - 6; k = k - 6; } if(k > 0) { s = s + arr[k-1]; k--; } if(k > 0) { s = s + arr[k-1]*3; k--; } if(k > 0) { s = s + arr[k-1]*2; k--; } if(k > 0) { s = s + arr[k-1]*6; k--; } if(k > 0) { s = s + arr[k-1]*4; k--; } if(k > 0) { s = s + arr[k-1]*5; k--; } cout << s%7; return 0; } Edited by author 16.11.2013 14:57 Edited by author 16.11.2013 14:57 Thats all ;) char c,ans; main(){ for(;(c=getchar())!='\n';ans=(ans*10+c-'0')%7); printf("%u\n",ans);
return 0; } |
почему код у меня работает а в тимусе на 1 тесте ошибка? | saharok | 1243. Divorce of the Seven Dwarfs | 27 Aug 2015 00:18 | 3 |
компилятор visual studio 2010 - 1wa c++11 -4wa c++14 -4wa КАК???!!! код #include <iostream> #include <string> using namespace std; int main() { long int a; cin >> a; if(a < 7){ cout << a; return 0; } if(a>=7) cout << a%7; } I think number's type long more. You don't used long long. |
Java's pretty suitable on this problem ;D | GastonFontenla | 1243. Divorce of the Seven Dwarfs | 24 Aug 2015 14:29 | 1 |
|
Help, I have a bug in the 5 test | PEDORENKO | 1243. Divorce of the Seven Dwarfs | 9 Aug 2015 03:18 | 2 |
#include <iostream> #include <math.h> using namespace std; int main(){ double x; int i; cin >> x; x = fmod (x, 7.0); printf("%.0f",x); system("pause"); return 0; } Edited by author 18.08.2014 21:49 it's ovbious that a number of 50 digits won't fit in a double. Such number wouldn't even fit in long long. You need other method... |
Pascal's criterion | Kergan | 1243. Divorce of the Seven Dwarfs | 23 Jun 2015 11:20 | 1 |
Just use it to solve this problem. |
c# accepted | pav1uxa | 1243. Divorce of the Seven Dwarfs | 31 Dec 2014 16:46 | 1 |
del Edited by author 06.01.2015 21:37 |
why? 2 test | DioniS | 1243. Divorce of the Seven Dwarfs | 3 Dec 2014 15:54 | 1 |
var a:array[1..20] of integer; n,n1:string; x,k,i,s,code:integer; begin read(n); x:=length(n); k:=x div 3; if x mod 3>0 then k:=k+1; for i:=1 to k do begin n1:=copy(n,x-3*i+1,3); val(n1,k,code); a[i]:=k; delete(n,x-2*i,3); end; k:=x div 3; if x mod 3>0 then k:=k+1; if k div 2=0 then begin a[1]:=-1*a[1]; a[3]:=-1*a[3]; a[5]:=-1*a[5]; a[7]:=-1*a[7]; a[9]:=-1*a[9]; a[11]:=-1*a[11]; a[13]:=-1*a[13]; a[15]:=-1*a[15]; a[17]:=-1*a[17]; end else begin a[2]:=-1*a[2]; a[4]:=-1*a[4]; a[6]:=-1*a[6]; a[8]:=-1*a[8]; a[10]:=-1*a[10]; a[12]:=-1*a[12]; a[14]:=-1*a[14]; a[16]:=-1*a[16]; end; for i:=1 to 17 do s:=s+a[i]; write(abs(s mod 7)); end. |
Output limit exceeded | Faruk | 1243. Divorce of the Seven Dwarfs | 30 Nov 2014 19:46 | 1 |
what's that means? Output limit exceeded. |
Java Coders!!! | Evgeniy[VVV] | 1243. Divorce of the Seven Dwarfs | 1 Sep 2014 23:36 | 1 |
Dear Java Coders, you will solve this problem so easy, if you know what is BigInteger means. |
AC 0.015s 180kb!!!!!!!!!!!!! | Hrayr | 1243. Divorce of the Seven Dwarfs | 14 Nov 2013 05:40 | 4 |
And? As you can see from the problem statistics, many people did it in 0.001s and some of them - with 117 kb =) |
easy for the Java coders | Konstantin Yovkov | 1243. Divorce of the Seven Dwarfs | 22 Jun 2013 14:47 | 2 |
If you use BigInteger the program is e-a-s-y :) Got AC from the first try :) Not only Java, but Python and Ruby as well. |