Page 3 of 11

Posted: Thu Nov 15, 2007 5:58 am
by lovemagic
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.

Wrong answer 11340!!!

Posted: Wed Nov 21, 2007 10:30 am
by mukit
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;
}


Posted: Wed Nov 21, 2007 11:03 am
by rio
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

Posted: Sun Jan 06, 2008 12:22 am
by Saul Hidalgo
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;
}


Re: 11340 - Newspaper

Posted: Mon May 19, 2008 11:08 pm
by mukit
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.

Re: 11340 - Newspaper

Posted: Mon Aug 18, 2008 12:52 am
by kbr_iut
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.

Re: 11340 - Newspaper

Posted: Sun Aug 24, 2008 5:15 pm
by Samiul
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) ;
	}
}

Re: 11340 - Newspaper

Posted: Mon Aug 25, 2008 9:22 am
by kbr_iut
pliz mention clearly what is ur problem.

Re: 11340 - Newspaper

Posted: Mon Aug 25, 2008 2:29 pm
by Samiul
This code is giving me WA.

Re: 11340 - Newspaper

Posted: Thu Sep 25, 2008 9:55 pm
by kbr_iut
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.

Re: 11340 - Newspaper

Posted: Fri Sep 26, 2008 2:21 pm
by Samiul
Yeah, your process worked. I am just curious why mine didn't.

Re: 11340 - Newspaper

Posted: Sat Sep 27, 2008 2:44 am
by kbr_iut
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.

Re: 11340 - Newspaper

Posted: Mon Dec 15, 2008 6:31 pm
by mak(cse_DU)
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.

Re: 11340 - Newspaper

Posted: Sun Dec 21, 2008 8:50 pm
by kbr_iut
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.

Re: 11340 - Newspaper

Posted: Mon Jan 05, 2009 12:52 am
by pok
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..
:(