Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
To admin | hich_am | 1404. Легко взломать! | 24 мар 2011 02:52 | 1 |
if the first caracter has a number less than 5 you should think on cyclic form. Exemple: the first carater given is d..the numro of 'd' is 3 and 3-5<0...so you have to add 26 and of course d comes y(because 3-5+26=24 and y has 24)... i whish i am clarified the point...good luck |
WA in Test 6 | Jorge Alejandro Millán Chang | 1404. Легко взломать! | 17 авг 2010 12:15 | 2 |
Does anyone knows what is tested in the test 6??? Or anyone have examples???? I had WA#6 too. Didn't use 'string' object because it is have char size of i-th element (-128,127), but you need more. Edited by author 17.08.2010 12:17 |
ok | nya | 1404. Легко взломать! | 9 май 2010 00:25 | 1 |
Edited by author 09.05.2010 11:37 |
WA 14, help please! | Smusenok Sergiy Andriyovich (KhAI) | 1404. Легко взломать! | 13 авг 2009 04:15 | 2 |
please give some test #include <stdio.h> int main() { int string[200]; int len=0; char ch; int count; ch=getchar(); while(!((ch=='\0')||(ch=='EOF')||(ch=='\n'))) { string[len]=ch-'a'; len++; ch=getchar(); } string[len]='\0'; //perviy prohod if(len==1) { printf("%c\0",string[0]-5); return 0; } if (string[0]<5) string[0]+=26; for(count=1;count<len;count++) { while(string[count]<string[count-1]) string[count]=string[count]+26; } //vtoroy prohod for(count=len-1;count>0;count--) { string[count]=string[count]-string[count-1]; } string[0]=string[0]-5; //tretiy prohod for(count=0;count<len;count++) { printf("%c",string[count]+'a'); } printf("\0"); return 0; } i find my mistake. don't forget about case,when you have 1 symbol! /////////////WA 14////////// if(len==1) { printf("%c\0",string[0]-5); return 0; } ///////////////AC//////////// if(len==1) { if (string[0]<5) string[0]+=26; printf("%c\0",string[0]-5+'a'); return 0; } |
why got WA, I have tested with several cases! thanks! | jacksparo | 1404. Легко взломать! | 8 авг 2009 20:35 | 2 |
#include <iostream> using namespace std; int main(void) { char encry[101]; int temp[101]; char dencry[101]; memset(encry, 0, 101*sizeof(char)); memset(temp, 0, 101*sizeof(int)); memset(dencry, 0, 101 * sizeof(char)); fgets(encry, 101, stdin); for (int i=0; i<strlen(encry)-1; i++) { temp[i] = encry[i] - 'a'; } if (temp[0] < 5) { temp[0] += 26; } for (int i=1; i<strlen(encry)-1; i++) { while (temp[i] < temp[i-1]) { temp[i] += 26; } } for (int i=strlen(encry)-1; i>0; i--) { temp[i] = temp[i] - temp[i-1]; dencry[i] = temp[i] + 'a'; } temp[0] -= 5; dencry[0] += temp[0] + 'a'; for (int i=0; i<strlen(encry)-1; i++) { cout << dencry[i]; } cout << endl; return 0; } got AC, after use n instead of strlen(encry)-1, where n is the number of characters. Caused by difference of strlen between compilers I think. |
why time limitexeted???? | ooo | 1404. Легко взломать! | 28 апр 2009 01:12 | 2 |
#include <iostream.h> int main() {const int n=100; char a[101]; int i,b[n]; for(i=0;i<n;i++) cin>>a[i]; for(i=0;i<n;i++) b[i]=a[i]-'a'; if(b[0]<=5) b[0]=b[0]+26; for(i=1;i<=n;i++) while(a[i]<a[i-1]) b[i]=b[i]+26; for(i=1;i<=n;i++) b[i]=b[i]-b[i-1]; b[0]=b[0]-5; for(i=0;i<n;i++) a[i]=(b[i]+'a'); for(i=0;i<n;i++) cout<<a[i]<<endl; return 0;} You have 6 - "for"!!! 1000^6 work over second Edited by author 28.04.2009 01:13 |
Can any1 help what is wrong here??? | Swifty | 1404. Легко взломать! | 12 мар 2009 14:11 | 2 |
var s:string; s1:array [1..100] of char; a,b:array [1..100] of integer; i,j,n:integer; begin readln(s); n:=length(s); for i:=1 to n do a[i]:=ord(s[i])-97; for i:=n downto 2 do {24+x-26 = 17} begin b[i]:=(a[i]+26-a[i-1])mod 26; s1[i]:=chr(b[i]+97); end; s1[1]:=chr(((a[1]-5)mod 26)+97); for i:=1 to n do write(s1[i]); readln; end. WA on 4th test!!! |
What a problem with my code, help please.. | Andrew Shirshov | 1404. Легко взломать! | 12 ноя 2008 00:43 | 1 |
It`s my Pascal code: type mass=array[1..101] of shortint; var i,j,j1:integer; s:string[101]; m1:mass; begin read(s); j1:=length(s); for i:=1 to j1 do begin m1[i]:=ord(s[i])-97; end; j:=5; for i:=1 to j1 do begin if m1[i]>=j-1 then begin m1[i]:=m1[i]-j; j:=m1[i]+j; end else begin m1[i]:=m1[i]+26-j; j:=m1[i]-26+j end end; for i:=1 to j1 do write(chr(m1[i]+97)); end. Give me some tests were my program will give wrong answer.. |
Compilation error | Romow Peter | 1404. Легко взломать! | 1 ноя 2008 00:17 | 4 |
#include <iostream.h> #include <stdio.h> using namespace std; int main() { char * s; cin >> s; int a[200] = {5}; for (int i = 0; i < strlen(s); i++) a[i+1] = (s[i] - 'a'); int n = strlen(s); for (int i = n; i >= 1; i--) { a[i] -= a[i-1]; if (a[i] < 0) a[i] += 26; } for (int i = 1; i <= n; i++) cout << (char)(a[i]+'a'); } why compilation error!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Your solution was compiled with the following errors: ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b(4): error: name must be a namespace name using namespace std; ^ ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b(9): warning #592: variable "s" is used before its value is set cin >> s; ^ ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b(12): error: identifier "strlen" is undefined for (int i = 0; i < strlen(s); i++) ^ ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b(14): error: identifier "strlen" is undefined int n = strlen(s); ^ ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b(25): warning #1: last line of file ends without a newline } ^ compilation aborted for ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b (code 2) Your compiling code-- #include <iostream.h> #include <stdio.h> #include <string.h> int main() { char * s; cin >> s; int a[200] = {5}; for (int i = 0; i < strlen(s); i++) a[i+1] = (s[i] - 'a'); int n = strlen(s); for (int i = n; i >= 1; i--) { a[i] -= a[i-1]; if (a[i] < 0) a[i] += 26; } for (int i = 1; i <= n; i++) cout << (char)(a[i]+'a'); }; and dont forget std namespace. |
1404 | Nana (rau) | 1404. Легко взломать! | 29 окт 2008 16:53 | 2 |
1404 Nana (rau) 28 янв 2008 00:18 #include <iostream.h> #include <string.h> void main() {char a[102]; int b[100],i,n; for (i=0;i<n;i++) cin>>a; for(i=0;i<n;i++) { b[i]= int(a[i]- 'a'); if(i==0){if(b[i]<5) b[i]+=26; cout<<char(b[i]-5+'a');}} else {if(b[i]<b[i-1]) b[i]+=26; coun<<char(b[i]-b[i-1]+'a');}} i don't understed where is my mistake Re: 1404 Nurbek_[KTMU MANAS] 29 окт 2008 16:53 |
Look my code and help me please!!! | SanKeaR | 1404. Легко взломать! | 24 авг 2008 00:47 | 1 |
Edited by author 03.09.2008 18:05 |
help!! | Vitaly | 1404. Легко взломать! | 3 фев 2008 22:22 | 1 |
help!! Vitaly 3 фев 2008 22:22 How can we get word "secret" from "xbduyr"? This is mistake!! Please, can you write the same table of this transformation? |
IT HASN'T RIGHT ANSWER | Sunrise Avenue | 1404. Легко взломать! | 28 окт 2007 17:57 | 3 |
This is very foolish task. I think, it hasn't right answer. It is not really to describe all sides of this program!!! It is not foolish, and quite easy problem. In other case, why so many authous solved it??? I think there are at least 1574 authors, who don`t think so. Authors Solved 1574 |
I'm good with you (C++ ->AC<-):) | alexutz_mircescu | 1404. Легко взломать! | 21 окт 2007 00:24 | 2 |
#include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> int i,u,n,minus,v[128],aux,auxs; char st[128],auxx; int main() { #ifndef ONLINE_JUDGE freopen("1404.in","r",stdin); freopen("1404.out","w",stdout); #endif scanf("%s",st); u=strlen(st); for(i=0;i<u;i++) v[i]=(int)(st[i])-'a'; for(i=0;i<u;i++) { if(i==0) v[i]+=26; else while(v[i]<v[i-1]) v[i]+=26; } minus=5; for(i=0;i<u;i++) { auxs=st[i]-st[i]+(v[i]-minus)%26+'a'; printf("%c",auxs); minus=v[i]; } return 0; } please stop post AC code. read FAQ. It is wrong to post AC code. if somebody asks you to help, then you can give him some hints. it is all. |
Only latin letters??? | AndryS | 1404. Легко взломать! | 30 июн 2007 03:41 | 1 |
Also what here it is wrong??? You see only latin letters!! using System; class Program { static void Main(string[] args) { string s = Console.ReadLine();
if (s != null) { int[] s1 = new int[s.Length]; int[] s3 = new int[s.Length]; string s2 = "abcdefghijklmnopqrstuvwxyz"; int tmp = 26; for (int i = 0; i < s.Length; i++) { if (i == 0) { s1[i] = s2.IndexOf(s[i]); if (s1[i] <= 4) { s1[i] += 26; } } else { s1[i] = s2.IndexOf(s[i]); while (s1[i] < s1[i - 1]) { s1[i] += tmp; } } } tmp = s1[1]; int tmp1; s1[1] -= s1[0]; for (int i = 2; i < s1.Length; i++) { tmp1 = s1[i]; s1[i] -= tmp; tmp = tmp1; } s = ""; s1[0] -= 5; for (int i = 0; i < s1.Length; i++) { s += s2[s1[i]]; } } Console.WriteLine(s);
} } |
No subject | PPaavveell | 1404. Легко взломать! | 24 апр 2007 17:57 | 1 |
Edited by author 24.04.2007 18:31 |
Why I am wrong in test4#~~~~~~~~~ | Ryan | 1404. Легко взломать! | 20 апр 2007 11:20 | 1 |
This is my code. {program Ryan; var n,i,k:integer; a:array[0..1000] of char; b:array[0..25] of 'a'..'z'; c,d:array[0..1000] of integer; begin for i:=0 to 25 do b[i]:=chr(i+97); i:=-1; repeat i:=i+1; read(a[i]); c[i]:=ord(a[i])-97; if (c[i]<26)and(i<>0) then while (c[i]<c[i-1])or (c[i]<26) do c[i]:=c[i]+26; until eoln; d[0]:=c[0]-5; for n:=0 to i do if n<>0 then d[n]:=c[n]-c[n-1]; for n:=0 to i do if d[n]>26 then begin d:=c; break; end; while k<i+1 do begin write(b[d[k]]); k:=k+1; end; end.} And I have sth. didn't understand. That is if I input 'asdffg',what is the output? Or if I input 'ghhllz',what is the output? Plz help me~ |
Timelimit in 3rd Test :( | Rh1N0 | 1404. Легко взломать! | 19 фев 2007 17:33 | 2 |
Why timelimit on 3rd test? My program listing: program hack; var ar : array[1..100] of byte; i,n : integer; word : string; begin readln(word); n := length(word); for i:=1 to n do begin ar[i] := ord(word[i]) - 97; end; begin for i:=2 to n do begin if ar[i] < ar[i-1] then while ar[i] < ar[i-1] do ar[i]:= ar[i] + 26; end; end; for i:= 0 to n-2 do begin ar[n-i] := ar[n-i] - ar[n-i-1]; end; ar[1] := ar[1] - 5; for i := 1 to n do begin word[i] := chr(97+ar[i]); end; writeln(word); end. ar : array[1..100] of byte; Your array overflow while ar[i] < ar[i-1] do ar[i]:= ar[i] + 26; this cycle becomes infinity Example ar[1]:=240+26 =10 Edited by author 19.02.2007 17:34 |