Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
runtime error python | Vitaly Nedzvetsky | 1493. В одном шаге от счастья | 10 мар 2023 00:23 | 1 |
import sys num = str(sys.stdin.readline().split()[0]) a = int(num[:3]) b = int(num[3:]) - 1 c = int(num[3:]) + 1 sum0 = sum([int(num) for num in str(a)]) sum1 = sum([int(num) for num in str(b)]) sum2 = sum([int(num) for num in str(c)]) if abs(sum0 - sum1 == 0) or abs(sum0 - sum2 == 0) or abs(sum1 - sum0 == 0) or abs(sum2 - sum0 == 0): print("Yes") else: print("No") |
WA 1, :( | klimvetoshkin | 1493. В одном шаге от счастья | 5 фев 2023 10:22 | 1 |
a = input() row = [] for i in a: row.append(i) for i in range(len(row)): row[i] = int(row[i]) suml = row[0] * 100 + row[1] * 10 + row[2] sumr = row[3] * 100 + row[4] * 10 + row[5] if suml - sumr == 1 or sumr - suml == 1: print('yes') else: print('no') |
Runtime error WA 14( Python) | Akashi | 1493. В одном шаге от счастья | 13 сен 2022 23:20 | 1 |
a = input() minussum=0 plussum=0 b =[0:3] c =[3:6] c=int(c) minus = c-1 plus = c+1 minus=str(minus) plus=str(plus) for i in minus: i=int(i) minussum+=i for i in plus: i=int(i) plussum+=i n=0 for i in b: i=int(i) n+=i if n == minussum or n == plussum: print("Yes") else: print("No")
Help please) Why re? Edited by author 13.09.2022 23:21 |
GDE OWIBKA ? (JAVA) | shaihin | 1493. В одном шаге от счастья | 13 янв 2020 16:53 | 4 |
import java.util.*; public class LuckyNumber{ public static void main(String args[]){ Scanner in = new Scanner(System.in); int x = in.nextInt(); int a1,a2,a3,b1,b2,b3; a1 = x/100000; a2 = (x/10000)%10; a3 = (x/1000)%10; b1 = (x/100)%10; b2 = (x/10)%10; b3 = x%10; if((a1+a2+a3) == (b1+b2+b3)) System.out.println("Lucky Number"); else if(a1+a2+a3-(b1+b2+b3)>1 ||(b1+b2+b3)-(a1+a2+a3)>1) { System.out.println("prostoi bilet"); } else System.out.println("Lucky Number budet sleduwii ili prediduwi bilet"); } } You should output "Yes" or "No" and nothing else |
AC in c++ | Yucheng | 1493. В одном шаге от счастья | 15 фев 2019 12:48 | 1 |
#include<iostream> using namespace std; int sum(int temp); int main(){ int a[6]; scanf("%1d%1d%1d%1d%1d%1d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]); int first=a[0]*100+a[1]*10+a[2]; int second=a[3]*100+a[4]*10+a[5]; if(a[3]==9&&a[4]==9&&a[5]==9){ cout<<"No"; return 0; } int pre=second-1; int next=second+1; if((sum(pre)==(a[0]+a[1]+a[2]))||(sum(next)==(a[0]+a[1]+a[2]))){ cout<<"Yes"; }else{ cout<<"No"; }
return 0; } int sum(int temp){ int count=0; do{ count+=(temp%10); temp/=10; }while(temp/10!=0); count+=temp; return count; } |
PASCAL WHY WA1?? | phloyd | 1493. В одном шаге от счастья | 15 дек 2018 04:31 | 2 |
Am I stupid or what? code seems to be working var x,a,b:integer; function sum(x:integer): INTEGER; var s:integer; begin while x>0 do begin s:=s+x mod 10; x:=x div 10; end; sum:=s; end; begin read (x); a:=x div 1000; b:=x mod 1000; if (sum(a)=sum(b+1)) or (sum(a)=sum(b-1)) then writeln ('Yes') else writeln ('No'); end. Pay attention to inc and dec in your code. You should do first x+1 and x-1. I hope you understand me |
Если будет ошибка на тесте 11 (WA11) | Diversus | 1493. В одном шаге от счастья | 27 июл 2018 20:01 | 2 |
Проверяйте пограничные ситуации, когда номер билета на входе 000000 или 999999 номера 000000 и 999999 проверять не надо,потому что сумма первых трёх цифр не отличается на единицу от суммы последних трёх цифр(по условию). |
Problem 1493 "One Step from Happiness" has been rejudged | Vladimir Yakovlev (USU) | 1493. В одном шаге от счастья | 3 апр 2018 04:39 | 1 |
New tests have been added. 86 authors have lost their AC. |
не проходит первый тест | Kety Pirozhkova | 1493. В одном шаге от счастья | 24 янв 2018 19:26 | 1 |
вообще не могу понять что не так. проходят пробные тесты,проходят тесты которые нашла в обсуждениях. если не трудно может покидаете тесты, плииз... var a,a1,a2,s1,s,ap,al,sm1p,sm2p,sm3p,smap,sm1l,sm2l,sm3l,smal,s2,s3:Integer; begin ReadLn(a); a1:=a+1; a2:=a-1; ap:=a1 div 1000; al:=a1 mod 1000; sm1p:=ap div 100; sm2p:=ap mod 100 div 10; sm3p:=ap mod 10; smap:=sm1p+sm2p+sm3p; sm1l:=al div 100; sm2l:=al mod 100 div 10; sm3l:=al mod 10; smal:=sm1l+sm2l+sm3l; if smal=smap then Writeln('YES') else begin ap:=a2 div 1000; al:=a2 mod 1000; sm1p:=ap div 100; sm2p:=ap mod 100 div 10; sm3p:=ap mod 10; smap:=sm1p+sm2p+sm3p; sm1l:=al div 100; sm2l:=al mod 100 div 10; sm3l:=al mod 10; smal:=sm1l+sm2l+sm3l; if smal=smap then Writeln('YES') else WriteLn('NO'); end; end. |
I think my code is right but it is not getting accepted. | Tanay | 1493. В одном шаге от счастья | 23 ноя 2017 13:44 | 1 |
I think my code is right but it is not getting accepted. Can anyone help me figure out what is wrong ? The python code is as follows: n=input() sum1=0 sum2=0 for i in range(0,3): sum1=sum1+(int(n[i])) for i in range(3,6): sum2=sum2+(int(n[i])) if(1==(abs(sum1-sum2)) or 0==sum1-sum2): print("Yes") else: print("No") Pls help me solve the issue Edited by author 23.11.2017 13:45 |
whats wrong with this code?it say wrong answer | sina roozegar | 1493. В одном шаге от счастья | 22 ноя 2017 21:34 | 1 |
#include<iostream> using namespace std; int main() { int x, y; int sum1 = 0, sum2 = 0; char n = 'n'; cin >> x; int max = x + 1; int min = x - 1; for (int i = 0; i <3; i++) { y = max % 10; max = max / 10; sum1 += y; } for (int i = 0; i < 3; i++) { y = max % 10; max = max / 10; sum2 += y; } if (sum2 == sum1) { n = 'y'; }
y = 0; sum1 = 0; sum2 = 0; for (int i = 0; i <3; i++) { y = min % 10; min = min / 10; sum1 += y; } for (int i = 0; i <3; i++) { y = min % 10; min = min / 10; sum2 += y; } if (sum2 == sum1) { n = 'y'; } if (n=='n') { cout << "no"; } else { cout << "yes"; } return 0; } |
No subject | Andrey | 1493. В одном шаге от счастья | 12 ноя 2016 19:26 | 1 |
#include <iostream> long int a,b,c,d,e,f,n,z,x,a1,a2; using namespace std; void main() { cin >>a; n=a%10; f=a%100; f=f/10; e=a%1000; e=e/100; d=a%10000; d=d/1000; c=a%100000; c=c/10000; b=a%1000000; b=b/100000; if ((n==9)||(f==9)||(e==9)) { z=(e+f+n)+1%10; } else { z=e+f+n; } if ((d==9)||(c==9)) { x=(b+c+d)+1%10; } else { x=b+c+d; } a1=z-x; a2=x-z; if ((a1==1)||(a2==1)) { cout <<"Yes"; } else { cout <<"No"; } } |
Help me please with this task! C | Igorabc1 | 1493. В одном шаге от счастья | 6 сен 2016 00:23 | 2 |
my code: #include <stdio.h> #include <math.h> #include <string.h> #include <conio.h> int SL (int n) { int q=n/1000, i, s=0; while (q>10) { s+=q%10; q/=10; } s+=q; return s; } int SR (int n) { int s=0,q=n%1000; while (q>10) { s+=q%10; q/=10; } s+=q; return s; } void main() { int S=0,T=0,N; scanf ("%d", &N); if ((SR(N+1)==SL(N+1))||(SR(N-1)==SL(N-1))) printf ("Yes"); else printf ("No"); } I remaked a bit your programm and it got acceped. What you need to change is SL and SR functions: int SL(int n){ int q=n/1000, i, s=0; while(q!=0){ s+=q%10; q/=10; }
return s; } int SR (int n){ int s=0, q=n%1000; while (q!=0) { s+=q%10; q/=10; }
return s; } Thanks for your code, i didn't need to write that myself :) |
AC (VB .NET 2010) | MEGAPLANET | 1493. В одном шаге от счастья | 24 авг 2016 07:55 | 1 |
I got AC on VB .NET 2010 !!! Write me on mail saucy_smile@mail.ru and I'll send you the source code :-) Edited by author 24.08.2016 08:07 Edited by author 24.08.2016 08:08 |
The solution is correct but test1 says it's wrong :/ | Arusyak | 1493. В одном шаге от счастья | 16 мар 2016 20:31 | 2 |
//Timus1493 #include <iostream> using namespace std; //Creates a copy and does not change the argument int sum_of_3(int num) { int result = 0;
for (int i = 1; i <= 3; i++) { result += num % 10; num /= 10; } return result; } int main () { int num; cin >> num;
int digit = num % 10, right = sum_of_3(num), left = sum_of_3(num / 1000);
if ((left > right && digit == 9) || (left < right && digit == 0)) cout << "No \n"; else cout << "Yes \n"; cout << num; return 0; } Fix output as task required - remove spaces after Yes and No, remove "cout << num;". |
Why? | Sergey | 1493. В одном шаге от счастья | 2 мар 2016 09:54 | 2 |
Why? Sergey 2 мар 2016 03:03 445219- No 4+4+5 = 13 2+1+9 = 12 13 and 12 = 1 Yes? Why not? "I'm one step from happiness," Vova thought, "either the previous or the next ticket is lucky." Is he right? So, you have to check if any of (445219-1) and (445219+1) is lucky. |
Test #8 : Run-time error; Python script: help me fellas | Neeraj Kumar | 1493. В одном шаге от счастья | 1 янв 2016 13:55 | 1 |
In a different IDE with all boundary conditions checked, it's working but it shows run-time error at test #8, not sure why. import sys def compute_sum(n): return int(n[0]) + int(n[1]) + int(n[2]) - int(n[3]) - int(n[4]) - int(n[5]) n = input() s2 = 1 s3 = 1 if int(n) == 0 or int(n) == 999999: print ('Yes') sys.exit() s1 = compute_sum(n) if len(str(int(n))) < 6: d = 6 - len(str(int(n))) s2 = compute_sum('0' * d + str(int(n) - 1)) s3 = compute_sum('0' * d + str(int(n) + 1)) else: s2 = compute_sum(str(int(n) - 1)) if len(str(int(n) + 1)) <= 6: s3 = compute_sum(str(int(n) + 1)) if abs(s2) == 0 or abs(s3) == 0: print ("Yes") else: print ("No") |
To admins. Example 2 1493. "В одном шаге от счастья". | Anton_Ageikov | 1493. В одном шаге от счастья | 6 ноя 2015 22:47 | 3 |
I disagree with the result in example 2 to the task 1493. According to the problem, must output "Yes", because 445219 in the summation of the digits gives 13 and 12. These numbers differ by 1. The example says "No". When checking the solution 2, the test system writes "Wrong answer". Please fix the problem or explain me the condition. You are asked to answer IF THE PREVIOUS OR THE NEXT TICKETS ARE LUCKY, NOT IF THE SUMS OF DIGITS DIFFER BY 1. |
Wrong test #6 help me friends please !!! | Jamshid Sattarov (TUIT Urgench) | 1493. В одном шаге от счастья | 2 ноя 2015 00:37 | 2 |
this is my solution #include <iostream> #include <cmath> using namespace std; int main() { long long a,b,s=0,d=0,k=0,jama,kk=0,ss=0,dd=0; cin>>b; a=b; b=b-1; while(b-1>0) { jama=b%10; k++; if(k<=3) { s+=jama; } else{ d+=jama; } b/=10; } int i=0; if(s-d==0 ) { i++; } a=a+1; int joma; while(a>0) { joma=a%10; kk++; if(kk<=3) { ss+=joma; } else{ dd+=joma; } a/=10; } if(ss-dd==0 ) { i++; } if(i>0) { cout<< "Yes"; } else cout<< "No"; return 0; } [delete] Edited by author 02.11.2015 00:38 Edited by author 02.11.2015 00:38 |
Why C++ help | Barbs | 1493. В одном шаге от счастья | 1 фев 2015 21:41 | 1 |
include <iostream> using namespace std; int main() { int N=0,a=0,b=0; cin>>N; a=(N/100000)+(N/10000-N/100000*10)+(N/1000-N/10000*10); b=(N/100-N/1000*10)+(N/10-N/100*10)+(N-N/10*10); if(a-1==b){ cout << "YES\n"; } else { cout << "NO\n"; } return 0; } |