11530 - SMS Typing

All about problems in Volume 115. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

ruhul_sust
New poster
Posts: 5
Joined: Tue Jul 27, 2010 8:01 pm

Re: 11530 - sms typing -- Why WA???? :(

Post by ruhul_sust »

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.
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Re: 11530 - sms typing -- Why WA???? :(

Post by sohel »

gets() after scanf() will not work.
ruhul_sust
New poster
Posts: 5
Joined: Tue Jul 27, 2010 8:01 pm

Re: 11530 - sms typing -- Why WA???? :(

Post by ruhul_sust »

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 ... :'( :( :( :( :(
ruhul_sust
New poster
Posts: 5
Joined: Tue Jul 27, 2010 8:01 pm

Re: 11530 - sms typing -- Why WA???? :(

Post by ruhul_sust »

thanks I got my Error and i fix it now && got AC....... :D :) :lol:
Mizanur Rahman(IUK)
New poster
Posts: 12
Joined: Wed Aug 18, 2010 12:07 pm

Re: 11530 - sms typing -- Why WA???? Please help me

Post by Mizanur Rahman(IUK) »

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;
}
anik.bit0104
New poster
Posts: 6
Joined: Thu Sep 23, 2010 1:50 pm
Location: Dhaka, Bangladesh

Re: 11530 - sms typing -- Why WA???? :(

Post by anik.bit0104 »

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;

}
I don't know where am i failing.. help me?
zahid0055
New poster
Posts: 1
Joined: Tue Apr 03, 2012 12:43 pm

11530 help

Post by zahid0055 »

Help me finding the error of my code

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;
}
getting Wrong Answer
Help me with some test cases
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11530 help

Post by brianfry713 »

Input:

Code: Select all

3

welcome to ulab
good luck and have fun
AC output:

Code: Select all

Case #1: 0
Case #2: 29
Case #3: 41
Check input and AC output for thousands of problems on uDebug!
EROR
New poster
Posts: 1
Joined: Sun Oct 21, 2012 6:07 pm

Re: 11530

Post by EROR »

In the Problem Statement here http://uva.onlinejudge.org/index.php?op ... oblem=2525 there is a line containing
Each line will contain at least 1 and at most 100 characters.
. 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.......??????????
:oops:
me33
New poster
Posts: 16
Joined: Wed Feb 19, 2014 10:08 pm

WA: 11530 Why????

Post by me33 »

I think everything is okay. but continuously getting WA.
plz help me. :( :cry:

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.
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: WA: 11850

Post by brianfry713 »

That doesn't look like the correct problem number
Don't use fflush(stdin);
Check input and AC output for thousands of problems on uDebug!
me33
New poster
Posts: 16
Joined: Wed Feb 19, 2014 10:08 pm

Re: WA: 11530 Why????

Post by me33 »

Sorry! My mistake.

The problem number is 11530
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: WA: 11530 Why????

Post by brianfry713 »

Don't use fflush(stdin);
Check input and AC output for thousands of problems on uDebug!
me33
New poster
Posts: 16
Joined: Wed Feb 19, 2014 10:08 pm

Re: WA: 11530 Why????

Post by me33 »

How can I take input in this loop???
Plz help
jaime21
New poster
Posts: 6
Joined: Wed Apr 09, 2014 4:36 pm

Re: 11530 - SMS Typing

Post by jaime21 »

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);
		}
}
	
}
Post Reply

Return to “Volume 115 (11500-11599)”