11547 - Automatic Answer

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

ary
New poster
Posts: 5
Joined: Mon Jan 05, 2009 2:43 pm

11547 - Automatic Answer

Post by ary »

Hello, i got wa for this question.. i dun bit understand the tens column means.. is it the nearest column n that is n divisible by 10 ??
here my code ..

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <sstream>
using namespace std;

int main(){
//freopen("11547.txt","r",stdin);
//freopen("11547O.txt","w",stdout);
long long n,sn;
stringstream buff;
string s,c;

int T,d;
cin>>T;
for(int z=0;z<T;z++){
s= "";
cin>>n;
n *= 567;
n /= 9;
n +=7492;
n *= 235;
n /=47;
n -=498;

if(n<0)
n *=-1;

buff<<n;
buff>>s;
buff.clear();

sn = s.length();

while(1){
if( sn > 10){
if(sn%10==0)
break;
}
else {
if(10%sn==0)
break;
}
sn--;
}

cout<<s[sn-1]<<endl;

}

return 0;
}
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 11547 - Automatic Answer WA!!

Post by Obaida »

In this problem you need to print the ten's column.
That means the number in the ten's position.

Code: Select all

Think a number 123. Then 2 is in ten's position.
And for 1234, 3 is in ten's position.
Try to use code tags. :)
try_try_try_try_&&&_try@try.com
This may be the address of success.
ary
New poster
Posts: 5
Joined: Mon Jan 05, 2009 2:43 pm

Re: 11547 - Automatic Answer WA!!

Post by ary »

hmm.. still dun quite understand, is it the second last number?
if the number is 12345678910, the number to be print is 1? em.. plz.. explain more.. :(
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 11547 - Automatic Answer WA!!

Post by Obaida »

Yes it's like this.
We say 10 as ten and 1 is in tens column.
123 as 1 hundred twenty three so 2 is in ten's column.
And same for all. You just need to print ten's and if no one in tens then 0.
try_try_try_try_&&&_try@try.com
This may be the address of success.
ary
New poster
Posts: 5
Joined: Mon Jan 05, 2009 2:43 pm

Re: 11547 - Automatic Answer WA!!

Post by ary »

ok, correct me if im wrong.. >> for this number,

9876920 > output 2
1232145512589 > 8
543264 > 6
6 > 0

is it like that?
ary
New poster
Posts: 5
Joined: Mon Jan 05, 2009 2:43 pm

Re: 11547 - Automatic Answer WA!!

Post by ary »

Ok, AC.. THANKs! :D
noor_aub
New poster
Posts: 26
Joined: Sat Aug 22, 2009 12:16 pm

11547 - Automatic Answer

Post by noor_aub »

I have made this code according to this problem set but the output is not coming.
Some body help me.

Code: Select all

#include<iostream>
using namespace std;

int main()
{
	_int64 re;
	int cas,number;
	cin>>cas;
	while(cas--)
	{
		cin>>number;
		re=0;
		re=(_int64)((((((number*567)/9)+7492)*235)/47)-498);
		printf("%I64d",re);

	}
	return 0;
}
sms.islam
New poster
Posts: 19
Joined: Sat Oct 10, 2009 10:28 am

Re: 11547 Not understand the algorithm

Post by sms.islam »

Read the problem description carefully.

After getting re=12345678 (imagine)
you have to show 7

more:
98745>4
2587416>1

hope it helps.
noor_aub
New poster
Posts: 26
Joined: Sat Aug 22, 2009 12:16 pm

Re: 11547 Not understand the algorithm

Post by noor_aub »

Still I dont unser stand the algorithm. Please tell me in details.
Eather
New poster
Posts: 28
Joined: Thu Jan 28, 2010 2:23 pm

Re: 11547 Not understand the algorithm

Post by Eather »

I did this and I got AC :D

Code: Select all

#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;

int main()
{
long long int n,t,i,j,res;

	while((scanf("%ld",&i))==1&& i>0)
	{
		for(j=0;j<i;j++)
		{
		scanf("%ld",&n);
		res = ((((((n*567)/9)+7492)*235)/47)-498);
  		if (res<0) 
			res = -res;
  		long long t = ((res%100)-(res%10))/10;
  		printf("%ld\n", t);
		}
	}
	return 0;
}[
mahi_seu.bd
New poster
Posts: 4
Joined: Mon Dec 06, 2010 8:25 pm
Location: Bangladesh
Contact:

Re: 11547 Not understand the algorithm

Post by mahi_seu.bd »

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
int n,t,i,p,k;
scanf("%d",&t);
for(i=1;i<=t;i++){
k=0;p=0;
scanf("%d",&n);
p=((((((n*567)/9)+7492)*235)/47)-498);
if(p<0)
p*=-1;
k=(p/10)%10;
printf("%d\n",k);
}return 0;
} :P :P
86400
New poster
Posts: 3
Joined: Thu Dec 13, 2012 12:08 am

11547 Automatic Answer

Post by 86400 »

I submitted this code for 11547 Automatic Answer problem and get 0.004=>0.008s. I'm a newbie and I wan't It's better (time < 0.004s). Please help me ...

Code: Select all

#include <stdio.h>
#include <string.h>
int t, n; 
char R[]={'0','2','3','5','6','8','9','1','2','4','5','7','8','0','1','3','4','6','7','9'};
int main()
{
    scanf("%d", &t);
    while(t--) {
        scanf("%d", &n);
        if(n>-118)
            n = (n-117)%20;
        else
            n = (-n-118)%20;
        putchar(R[n]);
        putchar('\n');
    }
    return 0;
}
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11547 Automatic Answer

Post by brianfry713 »

Your code doesn't match the sample I/O.

You probably won't be able to get a time better than 0.004 sec. Even this C code gets WA in 0.004 sec.

Code: Select all

main(){}
Check input and AC output for thousands of problems on uDebug!
86400
New poster
Posts: 3
Joined: Thu Dec 13, 2012 12:08 am

Re: 11547 Automatic Answer

Post by 86400 »

brianfry713 wrote:Your code doesn't match the sample I/O.

You probably won't be able to get a time better than 0.004 sec. Even this C code gets WA in 0.004 sec.

Code: Select all

main(){}
Thank. But I think putchar is faster than printf ???
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11547 Automatic Answer

Post by brianfry713 »

Yes, but you're still probably not going to get a runtime <0.004 sec.

read() and write() are faster than getchar() and putchar()
Check input and AC output for thousands of problems on uDebug!
Post Reply

Return to “Volume 115 (11500-11599)”