Page 1 of 16
10062 - Tell me the frequencies!
Posted: Sat Jan 19, 2002 4:46 am
by FlyDeath
What should the answer be if the input is a blank line??
thanks
Posted: Mon Mar 04, 2002 11:19 am
by ahanys
No case will be there. You use this imput reading:
char line[1001];
while (gets(line) != NULL) {
// do solution for each line
}
Your problem may be : If two
characters are present the same time print the information of the ASCII character with higher ASCII value first.
Hello
Posted: Wed Jun 05, 2002 8:29 pm
by Betovsky
my prog with sample input work great
but on the judge it gives W.A.
does any1 have any ideia of whats te prob?
or knows a better input sample to test ...
Thx
Posted: Thu Jun 13, 2002 1:48 am
by Betovsky
this is frustating ...
i was comparing input/output of my prog with a prog of a frined of mine
and it was all the same... but my gets a WA and hes get an aceppted
and we dont know whats wrong. Plzz some find the error ...
[c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int c[96];
void display(){
int i, x, n=99999;
while(n!=0){
for(i=0;i<96;i++){
if(n>c && c!=0){
n=c;
x=i;
continue;
}
if(n==c && x<i){
x=i;
continue;
}
}
if(n==0 || n==99999) break;
printf("%d %d\n", (x+32), n);
c[x]=0;
x = -1;
n = 99999;
}
}
void init(){
int i;
for(i=0;i<96;i++)
c=0;
}
int main(){
char linha[1000];
int check=0, i;
while(fgets(linha,1000,stdin)!=NULL){
if(strlen(linha)==1)
continue;
if(check == 1) printf("\n");
init();
for(i=0;i<strlen(linha)-1;i++){
c[(int) linha -32]++;
}
display();
check=1;
}
return 0;
}
[/c]
Thx..
Someone discovered?
Posted: Tue Aug 20, 2002 2:36 am
by mook
Someone discovered what is causing that problem? I have the same problem... with a lot of different algorithms..
Posted: Fri Sep 13, 2002 5:30 am
by arc16
finally found why i get WA for such an easy problem...
the problem desc said that input will be (in ascii value) between 33 - 127, but there will be character outside that limit!!!

After removing my ascii check condition, i get AC...
10062(wrong answer)
Posted: Thu Nov 21, 2002 11:07 am
by lendlice
I have wrong answer.Who can help me.
Code: Select all
#include<stdio.h>
#include<iostream.h>
#include<string.h>
main()
{
char a[1000];
int b[100],c=0,i=0,j=0,n=0,k=0,l=0,m=999,p=0,q=0,r=0,s=0,o=0;
for(k=0;k<=1000;k++)
a[k]=0;
for(k=0;k<=100;k++)
b[k]=0;
while(gets(a))
{
n=strlen(a);
for(i=0;i<n;i++)
{
if(a[i]>=32&&a[i]<=128)
{
j=a[i]-31;
b[j]++;
}
}
for(r=0;r<200;r++)
{
if(b[r]!=0)
s++;
}
for(c=0;c<=s;c++)
{
for(k=0;k<100;k++)
{
if(b[k]<=m && b[k]!=0)
m=b[k];
}
for(k=100;k>0;k--)
{
if(m!=999)
{
if(b[k]==m)
{
o=k+31;
cout << o;
cout <<" "<<m<<endl;
b[k]=0;
m=999;
s--;
}
}
}
}
}
}
Posted: Fri Dec 13, 2002 5:08 pm
by deddy one
don't use ascii check in your code , at first I used ascii check too, but it WA, when I removed it , it acc , eventhough mine was PE
Posted: Fri Dec 13, 2002 5:15 pm
by deddy one
thx arc16, I got acc after read your post here
10062 WA why??
Posted: Sat Dec 21, 2002 7:29 am
by takumi
why do my code get a WA i think nothing goes wrong with it???
can any body help me with this.
thanks...
#include <stdio.h>
int main()
{
char input[1001];
int i, temp, ascii[256];
for ( i = 0; i < 1001; i++ ) {
input = 0;
}
for ( i= 0; i < 256; i++ ) {
ascii = 0;
}
while ( gets(input) != NULL) {
for ( i = 0; i < 1001; i++ ) {
temp = input;
ascii[temp]++;
}
if ( input[0] == input[1] ) {
for ( i = 256; i > 1; i-- ) {
if ( ascii != 0 ) {
printf("%d = %d\n", i, ascii );
}
}
}
else {
for ( i = 1; i < 256; i++ ) {
if ( ascii != 0 ) {
printf("%d = %d\n", i, ascii );
}
}
}
for ( i = 0; i < 1001; i++ ) {
input = 0;
}
for ( i= 0; i < 256; i++ ) {
ascii = 0;
}
putchar('\n');
}
return 0;
}[cpp][/cpp][c][/c]
Re: 10062 WA why??
Posted: Sat Dec 21, 2002 9:07 am
by route
output contains an equal sign
& OUPUT:
AAA
256 = 6553144
65 = 3
??
Posted: Sat Dec 21, 2002 11:47 am
by takumi
i have change it with no equal sign but still WA
why is that?
RE:
Posted: Sat Dec 21, 2002 12:08 pm
by route
Actually, your program has some problems
1. the order
input :ABCDEF
output:
70 1
69 1
68 1
67 1
66 1
65 1
notice that the largest ascii value comes first
2. input:
AAA
256 = 6553144 (<---- why is it printed ?)
65 = 3
even when the input is nothing, your program also prints this line...
Posted: Sun Dec 22, 2002 5:40 am
by takumi
what do I print when I input a blank line
like '\n' or '\t' or should i just ignore it ?
Posted: Sun Dec 22, 2002 1:31 pm
by route
Whenever there are characters in the input, you should output their ascii values.
I think you should also output a blank line if the input is a blank line.