11547 - Automatic Answer
Moderator: Board moderators
11547 - Automatic Answer
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;
}
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;
}
Re: 11547 - Automatic Answer WA!!
In this problem you need to print the ten's column.
That means the number in the ten's position.
Try to use code tags. 
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_try_try_try_&&&_try@try.com
This may be the address of success.
This may be the address of success.
Re: 11547 - Automatic Answer WA!!
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..
if the number is 12345678910, the number to be print is 1? em.. plz.. explain more..

Re: 11547 - Automatic Answer WA!!
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.
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.
This may be the address of success.
Re: 11547 - Automatic Answer WA!!
ok, correct me if im wrong.. >> for this number,
9876920 > output 2
1232145512589 > 8
543264 > 6
6 > 0
is it like that?
9876920 > output 2
1232145512589 > 8
543264 > 6
6 > 0
is it like that?
Re: 11547 - Automatic Answer WA!!
Ok, AC.. THANKs! 

11547 - Automatic Answer
I have made this code according to this problem set but the output is not coming.
Some body help me.
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;
}
Re: 11547 Not understand the algorithm
Read the problem description carefully.
After getting re=12345678 (imagine)
you have to show 7
more:
98745>4
2587416>1
hope it helps.
After getting re=12345678 (imagine)
you have to show 7
more:
98745>4
2587416>1
hope it helps.
Re: 11547 Not understand the algorithm
Still I dont unser stand the algorithm. Please tell me in details.
Re: 11547 Not understand the algorithm
I did this and I got AC

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;
}[
-
- New poster
- Posts: 4
- Joined: Mon Dec 06, 2010 8:25 pm
- Location: Bangladesh
- Contact:
Re: 11547 Not understand the algorithm
#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;
}

#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;
}


11547 Automatic Answer
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;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11547 Automatic Answer
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.
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!
Re: 11547 Automatic Answer
Thank. But I think putchar is faster than printf ???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(){}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11547 Automatic Answer
Yes, but you're still probably not going to get a runtime <0.004 sec.
read() and write() are faster than getchar() and putchar()
read() and write() are faster than getchar() and putchar()
Check input and AC output for thousands of problems on uDebug!