Show all threads Hide all threads Show all messages Hide all messages |
My code is accepted. | mars | 1877. Bicycle Codes | 1 Mar 2024 21:15 | 2 |
#include<iostream> using namespace std; int main(){ int a,b, thief[10000],i=0; cin>>a; cin>>b; int count = 0; for (int i = 0;i<10000;i++){ thief[i] = i; // cout<<thief[i]<<" ";
} for(i=0;i<10000;i++){ //cout<<"first"<<i<<endl; if(a==thief[i]||b==thief[i+1]){ count++;
} // cout<<"thief["<<i<<"]"<<thief[i]<<"\t"<<"thief["<<i+1<<"]"<<thief[i+1]<<endl; i=i+1; //cout<<"thief"<<i<<endl;
} if(count>0) cout<<"yes"; else cout<<"no"; } This code is not very efficient. Try this code instead: #include <iostream> using namespace std; int main(){ int key1;cin>>key1; int key2;cin>>key2; if((key1%2==0) || key2%2!=0){ cout<<"yes"<<endl; } else{ cout<<"no"<<endl; } return 0; } Edited by author 01.03.2024 21:16 Edited by author 01.03.2024 21:16 |
C++ wrong answer test1 | hjkhg | 1877. Bicycle Codes | 30 Nov 2021 13:38 | 2 |
i checked it manually and answer was correct. Why does if fail? Code: #include <iostream> int main(){ std::string lock1, lock2; std::string result = "yes"; int code = 1; int lock_val1, lock_val2, cur_value; bool lock_state = false; std::cin>>lock1; std::cin>>lock2; lock_val1 = std::stoi(lock1); lock_val2 = std::stoi(lock2); while (code < 10000) { if (lock_state == true){ cur_value = lock_val1; } else{ cur_value = lock_val2; } if (code > lock_val1 && code > lock_val2){ result = "no"; break; } if (code == cur_value){ break; } lock_state = !lock_state; ++code; }
std::cout << result << std::endl; return 0; } Edited by author 30.11.2021 13:19 Edited by author 30.11.2021 13:19 Edited by author 30.11.2021 13:24 Edited by author 30.11.2021 13:37 It passed, there was a typo. |
Why Run Time error? 1WA Python | CatGirl | 1877. Bicycle Codes | 5 Aug 2020 17:56 | 3 |
a,b = map(int,input().split()) if (a % 2 == 0 and b % 2 != 0): print("yes") else: print("no") because data type should be string, not integer sorry, my bad. data type is correct, but you should input like that: a=int(input()) b=int(input()) |
памагите help | Богдан | 1877. Bicycle Codes | 5 Jun 2020 20:58 | 3 |
плиз напишите решение задачи 1877. Велосипедные коды please help piton 3.6 Edited by author 17.12.2018 19:09 Not piton, python ;) Я на Python решил (decide), а на плюсах(C++) то же решение не заходит(don`t work) Действительно, на С++ не проходит решение. Ни так ни сяк. |
WA32 | АРТЕМ | 1877. Bicycle Codes | 15 Jan 2020 02:50 | 1 |
WA32 АРТЕМ 15 Jan 2020 02:50 I wrote a stupid solution and got wa32. Help please! |
What's the meaning of the problem?? | zhao kai | 1877. Bicycle Codes | 17 Jul 2019 00:24 | 4 |
How did the thief steal the bicycle ?I'm not pretty sure. Is there some one telling me ? The thief steals the bicycle if he opens the lock, that is, if the code he tries is the same as the code for the lock. Test 1: Den's keys: 0001 0000 1st night 2nd night 3rd night 4th night ... ... ... All nights bike's key 0001 0000 0001 0000 - bad man 0000 0001 0003 0004 - result no no no no no Test 2: Den's keys: 0002 0001 1st night 2nd night 3rd night 4th night ... ... ... All nights bike's key 0002 0001 0002 0001 - bad man 0000 0001 0003 0004 - result no yes no no yes In the first test all nights result is "no". That why in the first test result is no. Thanks a lot for the explanation. |
ответ | Богдан | 1877. Bicycle Codes | 17 Dec 2018 19:29 | 1 |
ответ Богдан 17 Dec 2018 19:29 a=int(input()) b=int(input()) if (a%2) == 0 or (b%2) == 1: print('yes') else: print('no') |
Accepted | mylyt | 1877. Bicycle Codes | 17 Nov 2018 19:56 | 1 |
/* by thinking the combinations of the two locks,we get if the password number for lock1 is even or password number for lock2 is odd, the theif could open the lock. I guess that would be the easiest ideal,right? */ #include <iostream> using namespace std; int main() { int lock1, lock2; cin >>lock1 >>lock2; if (lock1 % 2 == 0 || lock2 % 2 != 0) cout << "yes" << endl; else cout << "no" << endl; return 0; } |
Please help) | AndriyKozak | 1877. Bicycle Codes | 2 Oct 2018 10:10 | 2 |
#include <stdio.h> int main() { char a[3],b[3]; gets(a); gets(b); int x; if (a[3]=='0'||a[3]=='2'||a[3]=='4'||a[3]=='6'||a[3]=='8') x=1; if (b[3]=='1'||b[3]=='3'||b[3]=='5'||b[3]=='7'||b[3]=='9') x=1; if(x==1) printf("yes"); else printf("no"); } The two codes are just two numbers, think about it this way. If I write more, the solution will be obvious and you will get nothing. |
Blya poconi daite cod plez | Rustam_True_Proger | 1877. Bicycle Codes | 14 Sep 2017 19:43 | 2 |
|
Wrong Answer (C). Which reason? | exe-cute-er | 1877. Bicycle Codes | 19 Jul 2017 23:43 | 2 |
#include <stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); if (a % 2 == 0 || b % 2 != 0) { printf("YES"); } else { printf("NO"); } return 0; } Posted by Deepto Shome Pritom 4 Feb 2017 21:06 Test 1: Den's keys: 0001 0000 1st night 2nd night 3rd night 4th night ... ... ... All nights bike's key 0001 0000 0001 0000 - bad man 0000 0001 0003 0004 - result no no no no no Test 2: Den's keys: 0002 0001 1st night 2nd night 3rd night 4th night ... ... ... All nights bike's key 0002 0001 0002 0001 - bad man 0000 0001 0003 0004 - result no yes no no yes In the first test all nights result is "no". That why in the first test result is no. try to understand .. happy coding Edited by author 19.07.2017 23:44 |
This is running well on Java | Farruh-WIUT | 1877. Bicycle Codes | 21 Jun 2017 04:44 | 2 |
import java.util.Scanner; /** * Created by macbookpro on 2/19/15. */ public class JavaThieves877 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int c1 = Integer.parseInt(scanner.nextLine()); int c2 = Integer.parseInt(scanner.nextLine()); if(c1 % 2==0 || c2 % 2!=0 ) { System.out.print("Yes"); } else if(c1 % 2 != 0 || c2% 2== 0) { System.out.print("No"); } } } Nevermind I didn't read that this is running well:) Edited by author 21.06.2017 04:49 |
Accepted in C | Shaykh Siddique | 1877. Bicycle Codes | 12 Jan 2017 14:32 | 2 |
#include<stdio.h> int main(void){ int a, b; scanf("%d %d", &a, &b); if(a%2==0 || b%2!=0) puts("yes"); else if(a%2!=0 || b%2==0) puts("no"); return 0; } else puts("no"); is enough |
Pascal and binary operations | Demenev Dmitriy | 1877. Bicycle Codes | 7 Mar 2016 19:55 | 4 |
I used binary operations to solve the problem and I didn't manage make my algorithm faster. My algorithm is too slow (0.015 sec). Could you give me a little advice how I can optimise my algorithm? My facebook: https://www.facebook.com/dmitriy.demenev.7Time is rounded here, so you can only see results like 0.001, 0.015, 0.031, 0.046, 0.062 etc. 0.001 and 0.015 are pretty much equal, and 0.015 can mean pretty much anything between 0.002 and 0.015. Like 0.001, 0.015 is an ideal time, there's nothing to optimize here. Only starting from 0.031 the program might be considered "slightly slow". Thank you, Jane. It was really important for me. I got crazy of this runtime. It was like a bolt out of the blue xD Good luck!. Btw, sorry for my English :D |
RunTime Error in test 15 (python) | 958 | 1877. Bicycle Codes | 20 Feb 2016 16:22 | 1 |
raw_input() is ok input() is Runtime error |
Python почему Runtime error | Vigi | 1877. Bicycle Codes | 5 Oct 2015 18:05 | 1 |
from random import randint v1 = '' v2 = '' cod1 = ''.join(map(str, [randint(0, 9) for _ in range(1, 5)])) cod2 = ''.join(map(str, [randint(0, 9) for _ in range(1, 5)])) while v1 != cod1 and v2 !=cod2: n = input().split() v1 = n[0] v2 = n[1] if v1 != cod1 and v2 != cod2: print('no') print('yes') |
why test 21 | vladimir | 1877. Bicycle Codes | 20 Sep 2015 23:30 | 1 |
var a,b :integer; begin readln(a,b); if a mod 2 = 0 then writeln('yes') else if b = 0 then writeln('no') else if b div 2 mod 2 = 0 then writeln('yes') else writeln('no'); end. |
I can't understand this problem mean | Nguyen Trung Hieu | 1877. Bicycle Codes | 1 Jun 2015 15:40 | 8 |
I can't understand this problem mean, someone can explain it for me? Why first test and second test have this result? Test 1: Den's keys: 0001 0000 1st night 2nd night 3rd night 4th night ... ... ... All nights bike's key 0001 0000 0001 0000 - bad man 0000 0001 0003 0004 - result no no no no no Test 2: Den's keys: 0002 0001 1st night 2nd night 3rd night 4th night ... ... ... All nights bike's key 0002 0001 0002 0001 - bad man 0000 0001 0003 0004 - result no yes no no yes In the first test all nights result is "no". That why in the first test result is no. Very Clear answer ! thank you :) perfect but in line "bad man" , he checks 0002 betwen "0001" and "0003" |
I need you help, nice folks...Its not working in Java..its correct | Farruh-WIUT | 1877. Bicycle Codes | 19 Feb 2015 02:37 | 1 |
import java.util.Scanner; public class JavaThieves877 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int c1 = Integer.parseInt(scanner.next()); int c2 = Integer.parseInt(scanner.next()); if (c1 % 2 == 0 || c2 % 2 != 0) { System.out.print("Yes"); } else if (c1 % 2 != 0 || c2 % 2 == 0) { System.out.print("No"); } } } |
why&i think solutions are same&& | Arseniy | 1877. Bicycle Codes | 21 Jan 2015 10:06 | 3 |
#include <stdio.h> using namespace std
void main() { __int64 a,b,i,f=0; scanf("%i64d",&a); scanf("%i64d",&b); if( ((a % 2)==0) || ( ( b % 2)== 1)) printf("yes"); else printf("no"); } it has wa32 on c But same alghoritm on delphi has ac& program Project2; {$APPTYPE CONSOLE} uses SysUtils; var a,b:integer; begin readln(a); readln(b); if( ( ( a mod 2 )= 0 ) or ( (b mod 2) = 1) ) then write('yes') else write('no'); end. Chto za fignya? Scanf can sometimes convert integers to octal. ie. 0132 |