11340 - Newspaper

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

Moderator: Board moderators

Postby lovemagic » Thu Nov 15, 2007 5:58 am

mohsincsedu wrote:

Code: Select all

Before post anything u must read the previous posts carefully....



i think i read them carefully. Or if i overlooked something, can u tell me the matter for which i m getting WA?

p.s. i use char & modify the char value by adding 128 before using it as a array index. I think u already saw it.
khobaib
lovemagic
Learning poster
 
Posts: 52
Joined: Thu Oct 02, 2003 11:38 am

Wrong answer 11340!!!

Postby mukit » Wed Nov 21, 2007 10:30 am

I'm getting wrong answer for several times. :evil:
Someone please help...
Code: Select all
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define MAX 15000
int main()
{
   int test;
   int nc;
   unsigned char ch;
   float sum=0.0;
   char str[MAX];
   long int x,j,i;
   float val[MAX]={0};
   long int nl;
   int p;
   cin>>test;
   for(i=0;i<test;i++)
   {
      cin>>nc;
      for(x=0;x<nc;x++)
      {
         cin>>ch>>val[int(ch)+256];
      }
      cin>>nl;
      while(1)
      {
         if(nl<0)break;
         gets(str);
         for(p=0;p<strlen(str);p++)
         {
            sum+=val[(int(str[p])+256)];
         }
         nl--;
      }
      cout<<sum/100.00<<"$"<<endl;
      sum = 0.0;
   }
   return 0;
}

mukit
New poster
 
Posts: 48
Joined: Wed Nov 21, 2007 10:09 am
Location: Dhaka , Bangladesh

Postby rio » Wed Nov 21, 2007 11:03 am

Try this io test until you get the correct output.
Input:
Code: Select all
2
2
a 3
z 100
2
this is a test.
aaaaaaaaaaaaaa.
1
a 3
1
zero

Output:
Code: Select all
0.45$
0.00$

-----
Rio
User avatar
rio
A great helper
 
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Postby Saul Hidalgo » Sun Jan 06, 2008 12:22 am

Hi ;), I take careful about the unsigned char, and i had been careful about the char '\n' , '\t', ' ', ...... but i got WA. Here is my code... thanks for your help.


Code: Select all
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>

using namespace std;

int costos[300];
int total;

int main(){
   int casos;
   cin >> casos;
   for (int caso=0; caso< casos; caso++){
      total=0;
      for (int h=0; h<300 ; h++) costos[h]=0;
      int k;
      cin >> k;
      unsigned char tempca;
      int tempco;
      for (int kk=0 ; kk<k ; kk++){
         getchar();
         tempca=getchar();
         cin >> tempco;
         costos[tempca]=tempco;
      }
      int lineas;
      cin >> lineas;
      string frase;
      getline(cin , frase);
      for (int linea=0;linea<lineas; linea++){
         getline(cin , frase);
         for (int o=0;o<frase.size() ; o++){
            total+=costos[frase[o]];
         }
      }
      double tempooo=total/100.0;
      printf("%.2f$\n" , tempooo);
   }
   return 0;
}

Saul Hidalgo
New poster
 
Posts: 18
Joined: Wed Jan 03, 2007 2:36 am
Location: Los Teques, Venezuela

Re: 11340 - Newspaper

Postby mukit » Mon May 19, 2008 11:08 pm

I updated my code but still WA :oops:
Someone please help
Here is my code :
Code: Select all
Forget it ...I got AC

Thank's in advance.
mukit
New poster
 
Posts: 48
Joined: Wed Nov 21, 2007 10:09 am
Location: Dhaka , Bangladesh

Re: 11340 - Newspaper

Postby kbr_iut » Mon Aug 18, 2008 12:52 am

I am not getting one thing.This problem is simply trivial problem.no trick, no special input.just do what they want.It will be AC.
I used char not unsigned char(in c++)
I dont feel headache with type of char positive or negetive.

It is one of the problems that can be AC in first submission.
one thing thing carefully about the output format.(one leading 0,not 2,so 4.00 is invalid);

hope it will help those who r still confused with what to do.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................
User avatar
kbr_iut
Experienced poster
 
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH

Re: 11340 - Newspaper

Postby Samiul » Sun Aug 24, 2008 5:15 pm

Can anybody help me with this problem ?

Code: Select all
#include<stdio.h>
#include<string.h>

int val[300] ;
int c[300] ;
char s[10010] ;

int main()
{
   int n , t , i , x ;
   long long int res ;
   char ch ;

//   freopen("c:\\1.txt" , "r" , stdin) ;

   scanf("%d\n" , &t) ;
   while(t-- > 0)
   {
      scanf("%d" , &n) ;
      gets(s) ;
      memset(val , 0 , sizeof(val)) ;
      memset(c , 0 , sizeof(c)) ;
      while(n-- > 0)
      {
         ch = getchar() ;
         scanf("%d" , &x) ;
         gets(s) ;
         val[ch + 128] = x ;
      }

      scanf("%d" , &n) ;
      gets(s) ;
      while(n-- > 0)
      {
         gets(s) ;
         for(i = strlen(s) - 1 ; i >= 0 ; i--)
            c[s[i] + 128]++ ;
      }

      for(i = 0 , res = 0 ; i < 300 ; i++)
         res += (long long int)val[i] * c[i] ;

      printf("%.2llf$\n" , (double)res / 100) ;
   }
}
Samiul
New poster
 
Posts: 36
Joined: Thu Dec 13, 2007 3:01 pm

Re: 11340 - Newspaper

Postby kbr_iut » Mon Aug 25, 2008 9:22 am

pliz mention clearly what is ur problem.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................
User avatar
kbr_iut
Experienced poster
 
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH

Re: 11340 - Newspaper

Postby Samiul » Mon Aug 25, 2008 2:29 pm

This code is giving me WA.
Samiul
New poster
 
Posts: 36
Joined: Thu Dec 13, 2007 3:01 pm

Re: 11340 - Newspaper

Postby kbr_iut » Thu Sep 25, 2008 9:55 pm

try to solve the problem with long(even no need long long)
The only thing u have to do is finding modulous by 100 in each step.
after calculating dollars and its scents then print
b careful about printing format after decimal point...
hope it helps.
if u r still not clear I will explain u more.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................
User avatar
kbr_iut
Experienced poster
 
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH

Re: 11340 - Newspaper

Postby Samiul » Fri Sep 26, 2008 2:21 pm

Yeah, your process worked. I am just curious why mine didn't.
Samiul
New poster
 
Posts: 36
Joined: Thu Dec 13, 2007 3:01 pm

Re: 11340 - Newspaper

Postby kbr_iut » Sat Sep 27, 2008 2:44 am

I told u to b careful about the output format
the problem says that:
......and "yy" number of cents with one leading zero if necessary.

For this input
Code: Select all
1
2
a 99
W 1
2
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzW


ur program gives.
Code: Select all
1.00$

correct output should be
Code: Select all
1.0$

hope it will help.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................
User avatar
kbr_iut
Experienced poster
 
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH

Re: 11340 - Newspaper

Postby mak(cse_DU) » Mon Dec 15, 2008 6:31 pm

kbr_iut wrote:I told u to b careful about the output format
the problem says that:
......and "yy" number of cents with one leading zero if necessary.

For this input
Code: Select all
1
2
a 99
W 1
2
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzW


ur program gives.
Code: Select all
1.00$

correct output should be
Code: Select all
1.0$

hope it will help.


I am not agree with kbr_iut.....
Output of above input will be 1.00$(may be 1.0$ also correct).
No need to use long long.
My output section which give me AC.
Code: Select all
cout<<res/100<<".";
printf("%02d$\n",res%100);

NB: I handled unsigned char.
Mak
Help me PLZ!!
mak(cse_DU)
Learning poster
 
Posts: 72
Joined: Tue May 30, 2006 5:57 pm
Location: bangladesh

Re: 11340 - Newspaper

Postby kbr_iut » Sun Dec 21, 2008 8:50 pm

mak(cse_DU) wrote:
I am not agree with kbr_iut.....
Output of above input will be 1.00$(may be 1.0$ also correct).
No need to use long long.
My output section which give me AC.
Code: Select all
cout<<res/100<<".";
printf("%02d$\n",res%100);

yes u r right. both of them are correct. I just did it according to the problem statement.
and u r also right about the datatype .int or long is enough to get AC.
thanx for the correction.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................
User avatar
kbr_iut
Experienced poster
 
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH

Re: 11340 - Newspaper

Postby pok » Mon Jan 05, 2009 12:52 am

getting runtime error..
pls someone help me..
what can i do for that..

Code: Select all
#include<stdio.h>
#include<string.h>
#include<ctype.h>

char a[1000],c[150009][10009],d[10],e[10],q;

int main()
{
   long n,i,m;
   long b[1000],o,j,p,k,len,l,sum=0,y,z,x;
   

   scanf("%ld",&n);

   for(i=0;i<n;i++)
   {
      scanf("%ld",&m);
      
      gets(e);
      
      for(j=0;j<m;j++)
      {
         scanf("%c %ld",&a[j],&b[j]);
         scanf("%c",&q);
      }      
         
      scanf("%ld",&o);
      scanf("%c",&q);

      for(x=0;x<o;x++)
         gets(c[x]);

      sum=0;

      for(j=0;j<m;j++)
      {
         p=0;
         for(k=0;k<o;k++)
         {
            len=strlen(c[k]);
            for(l=0;l<len;l++)
               if(a[j]==c[k][l])
                  p++;
         }
         printf("%c %ld\n",a[j],p);
         sum=sum+(p*b[j]);
         printf("%ld\n",sum);
      }

      y=sum%100;
      z=sum/100;

      printf("%ld.%ld$",z,y);
      printf("\n");
   }

   return 0;
}


do some thing..
:(
pok
New poster
 
Posts: 25
Joined: Sun Nov 09, 2008 11:04 pm

PreviousNext

Return to Volume CXIII

Who is online

Users browsing this forum: Google [Bot] and 0 guests