11530 - SMS Typing
Moderator: Board moderators
-
- New poster
- Posts: 5
- Joined: Tue Jul 27, 2010 8:01 pm
Re: 11530 - sms typing -- Why WA???? :(
I m new in uva forum.Next time i'll follow ur advise. Thanks 4 ur advise.
But I m still in problem with this easy problem.I could not find any solution in any previous post .
I m frustrated :0
please help me.
But I m still in problem with this easy problem.I could not find any solution in any previous post .
I m frustrated :0
please help me.
-
- New poster
- Posts: 5
- Joined: Tue Jul 27, 2010 8:01 pm
Re: 11530 - sms typing -- Why WA???? :(
i can't understand what u say.
gets() does not do any work means ?????
I try scanf rather using gets() but still WA!!!!
((((
hELp ME ... :'(
![:(](./images/smilies/icon_frown.gif)
gets() does not do any work means ?????
I try scanf rather using gets() but still WA!!!!
![:(](./images/smilies/icon_frown.gif)
hELp ME ... :'(
![:(](./images/smilies/icon_frown.gif)
![:(](./images/smilies/icon_frown.gif)
![:(](./images/smilies/icon_frown.gif)
![:(](./images/smilies/icon_frown.gif)
-
- New poster
- Posts: 5
- Joined: Tue Jul 27, 2010 8:01 pm
Re: 11530 - sms typing -- Why WA???? :(
thanks I got my Error and i fix it now && got AC.......
![:lol:](./images/smilies/icon_lol.gif)
![:D](./images/smilies/icon_biggrin.gif)
![:)](./images/smilies/icon_smile.gif)
![:lol:](./images/smilies/icon_lol.gif)
-
- New poster
- Posts: 12
- Joined: Wed Aug 18, 2010 12:07 pm
Re: 11530 - sms typing -- Why WA???? Please help me
Code: Select all
#include<iostream.h>
#include<stdio.h>
int main()
{
long int i,n,count;
char a;
cin>>n;
for(i=0;i<n;i++)
{
count=0;
a=getchar();
while(a!='\n')
{
if(a=='a'||a=='d'||a=='g'||a=='j'||a=='m'||a=='p'||a=='t'||a=='w'||a==' ')
count=count+1;
else if(a=='b'||a=='e'||a=='h'||a=='k'||a=='n'||a=='q'||a=='u'||a=='x')
count=count+2;
else if(a=='c'||a=='f'||a=='i'||a=='l'||a=='o'||a=='r'||a=='v'||a=='y')
count=count+3;
else if(a=='s'||a=='z')
count=count+4;
a=getchar();
}
printf("Case #%ld: %ld\n",i+1,count);
//cout<<"Case #"<<i+1<<": "<<count;
//cout<<endl;
}
return 0;
}
-
- New poster
- Posts: 6
- Joined: Thu Sep 23, 2010 1:50 pm
- Location: Dhaka, Bangladesh
Re: 11530 - sms typing -- Why WA???? :(
Code: Select all
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;
int posFinder(char c);
int main()
{
int numOfTestCases;
string s;
int sumOfPos=0;
int caseCounter=0;
char dummy;
scanf("%d%c",&numOfTestCases,&dummy);
for (int i=0;i<numOfTestCases ;i++ )
{
caseCounter++;
getline(cin,s);
for (int i=0;i<s.size() ;i++ )
{
sumOfPos=sumOfPos+posFinder(s[i]);
}
cout<<"Case #"<<caseCounter<<": "<<sumOfPos<<endl;
sumOfPos=0;
}
return 0;
}
int posFinder(char c)
{
char one[8]={'a','d','g','j','m','p','t','w'};
char two[8]={'b','e','h','k','n','q','u','x'};
char three[8]={'c','f','i','l','o','r','v','y'};
char four[2]={'s','z'};
if (strchr(one,c)!=NULL || c==' ') return 1;
else if (strchr(two,c)!=NULL) return 2;
else if (strchr(three,c)!=NULL) return 3;
else if (strchr(four,c)!=NULL) return 4;
}
11530 help
Help me finding the error of my code
getting Wrong Answer
Help me with some test cases
Code: Select all
#include<stdio.h>
#include<string.h>
int main()
{
char s[101];
int t,i,j,count=0;
scanf("%d\n",&t);
for(i=0;i<t;i++)
{
gets(s);
int len=strlen(s);
for(j=0;j<len;j++)
{
if(s[j]==' '||s[j]=='a'||s[j]=='d'||s[j]=='g'||s[j]=='j'||s[j]=='m'||s[j]=='p'||s[j]=='t'||s[j]=='w'||s[j]==' ')
count=count+1;
else if(s[j]=='b'||s[j]=='e'||s[j]=='h'||s[j]=='k'||s[j]=='n'||s[j]=='q'||s[j]=='u'||s[j]=='x')
count=count+2;
else if(s[j]=='c'||s[j]=='f'||s[j]=='i'||s[j]=='l'||s[j]=='o'||s[j]=='r'||s[j]=='v'||s[j]=='y')
count=count+3;
else if(s[j]=='s'||s[j]=='z')
count=count+4;
}
printf("Case #%d: %d\n",i+1,count);
count=0;
}
return 0;
}
Help me with some test cases
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11530 help
Input:
AC output:
Code: Select all
3
welcome to ulab
good luck and have fun
Code: Select all
Case #1: 0
Case #2: 29
Case #3: 41
Check input and AC output for thousands of problems on uDebug!
Re: 11530
In the Problem Statement here http://uva.onlinejudge.org/index.php?op ... oblem=2525 there is a line containing
![:oops:](./images/smilies/icon_redface.gif)
. But in the input there may be some inputs where the string is blank. may be one of blank string starts the input file. Can the site update this problems.......??????????Each line will contain at least 1 and at most 100 characters.
![:oops:](./images/smilies/icon_redface.gif)
WA: 11530 Why????
I think everything is okay. but continuously getting WA.
plz help me.
my code.
plz help me.
![:(](./images/smilies/icon_frown.gif)
![:cry:](./images/smilies/icon_cry.gif)
my code.
Code: Select all
Removed After AC
Last edited by me33 on Fri Feb 28, 2014 9:20 pm, edited 3 times in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: WA: 11850
That doesn't look like the correct problem number
Don't use fflush(stdin);
Don't use fflush(stdin);
Check input and AC output for thousands of problems on uDebug!
Re: WA: 11530 Why????
Sorry! My mistake.
The problem number is 11530
The problem number is 11530
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: WA: 11530 Why????
Don't use fflush(stdin);
Check input and AC output for thousands of problems on uDebug!
Re: WA: 11530 Why????
How can I take input in this loop???
Plz help
Plz help
Re: 11530 - SMS Typing
Hello! I need help!! UVA keeps telling me runtime error! Can't find the bug
Code: Select all
import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int i, tc, j, sum;
char c;
String input;
tc = sc.nextInt();
sc.nextLine();
sc.nextLine();
for(i=1; i<=tc; i++){
input = sc.nextLine();
sum = 0;
for(j=0; j<input.length(); j++){
c = input.charAt(j);
if( c=='a' || c=='d' || c=='g' || c=='j' || c=='m' || c=='p' || c=='t' || c=='w' || c==' ' ){
sum += 1;
}
else if( c=='b' || c=='e' || c=='h' || c=='k' || c=='n' || c=='q' || c=='u' || c=='x' ){
sum += 2;
}
else if( c=='c' || c=='f' || c=='i' || c=='l' || c=='o' || c=='r' || c=='v' || c=='y' ){
sum += 3;
}
else if( c=='s' || c=='z' ){
sum += 4;
}
}
System.out.format("Case #%d: %d\n", i, sum);
}
}
}