Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
Страница 1 |
My Sample's Output is 114 but I have WA in 1st test case! | Moein Fatehi | 1567. SMS-спам | 22 сен 2011 13:33 | 1 |
|
My Sample's Output is 114 but I have WA in 1st test case! | Moein Fatehi | 1567. SMS-спам | 22 сен 2011 13:33 | 1 |
|
WA#8 | Tom | 1567. SMS-спам | 12 окт 2014 01:01 | 5 |
WA#8 Tom 6 авг 2011 19:46 what s wrong this time ? anybody ? #include<iostream> #include<string> using namespace std; char napis[1001]={0}; char tab[35]={0}; int tab1[35]={0}; int main(){ tab[0]=*"a"; tab1[0]=1; tab[1]=*"b"; tab1[1]=2; tab[2]=*"c"; tab1[2]=3; tab[3]=*"d"; tab1[3]=1; tab[4]=*"e"; tab1[4]=2; tab[5]=*"f"; tab1[5]=3; tab[6]=*"g"; tab1[6]=1; tab[7]=*"h"; tab1[7]=2; tab[8]=*"i"; tab1[8]=3; tab[9]=*"j"; tab1[9]=1; tab[10]=*"k"; tab1[10]=2; tab[11]=*"l"; tab1[11]=3; tab[12]=*"m"; tab1[12]=1; tab[13]=*"n"; tab1[13]=2; tab[14]=*"o"; tab1[14]=3; tab[15]=*"p"; tab1[15]=1; tab[16]=*"q"; tab1[16]=2; tab[17]=*"r"; tab1[17]=3; tab[18]=*"s"; tab1[18]=1; tab[19]=*"t"; tab1[19]=2; tab[20]=*"u"; tab1[20]=3; tab[21]=*"v"; tab1[21]=1; tab[22]=*"w"; tab1[22]=2; tab[23]=*"x"; tab1[23]=3; tab[24]=*"y"; tab1[24]=1; tab[25]=*"z"; tab1[25]=2; tab[26]=*"."; tab1[26]=1; tab[27]=*","; tab1[27]=2; tab[28]=*"!"; tab1[28]=3; tab[29]=*" "; tab1[29]=1;
int i=0,j=0,k=0,licznik=0; cin.getline (napis, 1000); k = strlen(napis); for(i=k-1;i>=0;i--){ for(j=0;j<30;j++){ if(napis[i]==tab[j]){ licznik+=tab1[j]; } } napis[i]=0; } cout << licznik; getchar(); return 0; } salam navid,dasdet dard nakone AC gereftam!!!! cena. Thx, but i can not understand why this has helped) After two minutes I realized ... '\0' symbol :D Edited by author 12.10.2014 01:03 |
how can i take the line? | shahmohammadi | 1567. SMS-спам | 9 июл 2011 21:17 | 2 |
what is the last character in the line? '\0' or '\n' when i use cin>>s; or scanf("%s",&s); it only take the first word. so how can i take the line? thank you. you may get the whole line using gets(s) (defined in cstdio) or cin.getline(s) (iostream). also you may get characters from input by 1 char. char c; while ((c= getchar()) != EOF) { /* your code */ } or char c; while (cin >> c) { ... } Edited by author 09.07.2011 21:17 |
GOT AC, all genius is simple | son1g | 1567. SMS-спам | 28 июн 2011 13:00 | 1 |
#include<iostream> #include<math.h> #include<conio.h> #include<string> using namespace std; int main() { char s; int count = 0; cin >> noskipws; while (cin >> s) { if ((s=='a')|| (s=='d')|| (s=='g')|| (s=='j')|| (s=='m')|| (s=='p')|| (s=='s')|| (s=='v')|| (s=='y')|| (s=='.')|| (s==' ')) {count+=1;} if ((s=='b')|| (s=='e')|| (s=='h')|| (s=='k')|| (s=='n')|| (s=='q')|| (s=='t')|| (s=='w')|| (s=='z')|| (s==',')) {count+=2;} if ((s=='c')|| (s=='f')|| (s=='i')|| (s=='l')|| (s=='o')|| (s=='r')|| (s=='u')|| (s=='x')|| (s=='!')) {count+=3;} } cout << count; getch(); return 0; } PS I wanted to use "(int(s)-97)%3". |
what wrong?! | Gelioscope | 1567. SMS-спам | 28 июн 2011 03:50 | 2 |
#include <stdio.h> #include <string.h> #define ulong unsigned long void main () { #ifndef ONLINE_JUDGE freopen("Data.txt","rt",stdin); freopen("Output.txt","wt",stdout); #endif char slogan[1001]; ulong cost=0,i; fgets(slogan,1001,stdin); for(i=0;i<strlen(slogan);++i) { if(slogan[i]>='a'&&slogan[i]<='z') { if((slogan[i]-'a')%3==0) { ++cost; continue; } if((slogan[i]-'a')%3==1) { cost+=2; continue; } cost+=3; continue; } if(slogan[i]==' '||slogan[i]=='.') { ++cost; continue; } if(slogan[i]==',') { cost+=2; continue; } cost+=3; } printf("%lu",cost); } why i get wa1?! Edited by author 28.06.2011 01:33 Ok, i got ac. The thing was that fgets reads also '\n' and handled it as '!', before finish the program. But i don't understand why simple printf("%lu",cost-3) was not enough and had to append the condition? In fact, all the other possibilities characters are handled above... |
Question | Alisher | 1567. SMS-спам | 6 июн 2011 12:59 | 2 |
Can we have any numbers in our input text??? No. Read problem description: "Slogan consists of words, spaces, commas, full stops and exclamation marks. All the words consist of lowercase english letters". And no any numbers there. |
WA on Test#8! | ░▒▓ Nguyễn Kim Vỹ ▓▒░ | 1567. SMS-спам | 30 ноя 2012 14:25 | 2 |
Please tell me why this program give WA on test8, thanks! #include <iostream> using namespace std; void main() { int sum=0; char s[1000]; first: while(cin.getline(s,1000)) { for(int i=0;i<strlen(s);i++) { switch(s[i]) { case'a':case'd':case'g':case'j':case'm':case'p':case's':case'v':case'y':case'.':case' ': sum+=1; break; case'b':case'e':case'h':case'k':case'n':case'q':case't':case'w':case'z':case',': sum+=2; break; case'c':case'f':case'i':case'l':case'o':case'r':case'u':case'x':case'!': sum+=3; break; } } } cout<<sum; } dude,that's my problem too,plz tell me if you got the solution. thanx==>cena |
To type “!”, press “0” three times. ?? should be four times, right? | Zhihua Lai | 1567. SMS-спам | 8 апр 2010 10:55 | 3 |
#include <iostream> using namespace std; int cnt(char ch) { if ((ch >= 'a') && (ch <= 'z')) { return (((int)(ch - 'a') % 3) + 1); } switch (ch) { case '#': return (1); break; case ' ': return (2); break; case '0': return (1); break; case '.': return (2); break; case ',': return (3); break; case '!': return (4); break; } return (0); } int main() { int n = 0; char ch; while (cin.get(ch)) { n += cnt(ch); } cout << n << endl; return (0); } what is wrong with my code??? i got 122 at the sample test,,,,, could you help me ?? i cannot figure it out.. thanks.. omg... my mistake in understanding the problem... got AC now.... |
THE EXAMPLE TEST IS WRITE !! | yaho0o0 | 1567. SMS-спам | 23 окт 2009 01:59 | 3 |
My AC program gives 114 for the first test !! Maybe "RIGHT", not "WRITE"))) |
the example result is wrong ! wrong = 114, right = 113 | Phan Hoài Nam - Đại học Ngoại ngữ Tin Học TP.HCM | 1567. SMS-спам | 10 сен 2011 12:39 | 4 |
I calculate the example and there is only 113, i add 1 to the result and get WA hundreds of times. I no longer add 1 to the result and get AC ! Therefore, my AC program give the result of 133 instead of 114 in the example. It's very very very simple ! there is only one line, no number, no strange letter ! Edited by author 11.03.2009 13:11 you are not write my AC program cout 114 I confirm that the example is wrong. My AC source returns 113. I had some trouble getting AC with the '\n' character. The problem statement says that you may find such characters in the input but nothing about their price. I valued them at 0 and got AC. to Spatarel Dan Constantin: You are wrong, your AC solution returns 114. :) The example is finished with an end of line. |
if your language is c++, you can use cin.get(ch). it's easy | Megatron | 1567. SMS-спам | 17 фев 2009 18:40 | 1 |
Edited by author 17.02.2009 18:40 |
It shows 114. But I have WA in 1 test. why? (my eng isn't good) | Lareon | 1567. SMS-спам | 5 янв 2009 10:05 | 1 |
|
Test 8(EOL) | 49warrior | 1567. SMS-спам | 21 окт 2008 15:33 | 1 |
Replace EOL on '^z' - Ctrl + z - end of input. I use that and got AC. |
What's WA#2?? | alexandresv | 1567. SMS-спам | 31 май 2008 17:33 | 1 |
What's problems in test 2? |
got ac | Anupam Ghosh,Bengal Engg and Sc Uni,MtechIT,2006-09,India | 1567. SMS-спам | 28 апр 2008 16:38 | 1 |
got ac Anupam Ghosh,Bengal Engg and Sc Uni,MtechIT,2006-09,India 28 апр 2008 16:38 this is a simple problem just try to find position of alphabet in a single button and add the value to sum.good luck. |
Something is wrong with this problem!!! | Varduhy | 1567. SMS-спам | 12 фев 2008 22:18 | 5 |
Edited by author 12.02.2008 22:20 Try such test: pokupaite gvozdi tolko v kompanii gvozdederov i tovarischi!#9654 My AC program output:119 Your program output:113 Good luck! Edited by author 12.02.2008 22:20 Maybe cin.getline() works uncorrectly. Try such way: [code deleted] and you'll get AC. Edited by author 13.02.2008 18:36 Thank you very much, as while studying your solution I understood what was wrong with my program! My program readed only one line! But yours could read more. I changed mine : from cin.getline(a,1000) ... to while(cin.getline(a,1000)) { ... } and got AC! There is a wrong sentence in the text of the problem: "The single line of input contains the slogan. " "The single" had made me think that way. So thank you one more time! :) |
I got AC! Place your achievements here! | Access Violation | 1567. SMS-спам | 21 янв 2022 10:04 | 4 |
Edited by author 05.12.2007 18:27 How do you get 0.001 sec? I'm quite sure there's nothing to improve in my code. I get 0.015 sec using FreePascal. Where do I go wrong?? Как Вы достигаете 0.001 секунды? Я не вижу где можно улучшить код для FreePascal. Есть идеи? var c: array[32..122] of byte; n, i, sum: integer; s: string; begin c[32] := 1; c[33] := 3; c[44] := 2; c[46] := 1; c[121] := 1; c[122] := 2; for i := 97 to 120 do c[i] := (i - 97) mod 3 + 1; readln(s); n := length(s); sum := 0; for i := 1 to n do sum := sum + c[byte(s[i])]; writeln(sum); end. |
The last character in first line could be '\n' (-) | diver_ru (Fishburg SAAT) | 1567. SMS-спам | 3 дек 2007 15:48 | 2 |
I read this post and I am surprised. It sais that input consists of a single line; I use that and I get wa on test 8; I read 2 lines and I get ac. Smth is wrong; I have also read that the line of input can contain white spaces.I understand that '\n' is a ws but if you put '\n' than you have 2 lines! Please post a response. |
No subject | Izverg | 1567. SMS-спам | 5 мар 2009 18:17 | 3 |
What's the Duck????????????? Edited by moderator 06.10.2007 17:13 Darkwing Duck Edited by moderator 06.10.2007 17:12 |