10515 - Powers Et Al.
Moderator: Board moderators
test cases!
Input:
12 10000
1 1000
2313242341234 100000
32872342144876231874687236872364987164876239874698721649823149823749854354356490487239759843 4359000000000000004354354356463464356346435643574839579473950739480702750847d239586345
33333333333333333333333333333333333333333333333333333333333333333333 3222222222234433222222222222222222222342342344444444444
1 1
0 0
output:
6
1
6
3
1
1
12 10000
1 1000
2313242341234 100000
32872342144876231874687236872364987164876239874698721649823149823749854354356490487239759843 4359000000000000004354354356463464356346435643574839579473950739480702750847d239586345
33333333333333333333333333333333333333333333333333333333333333333333 3222222222234433222222222222222222222342342344444444444
1 1
0 0
output:
6
1
6
3
1
1
aaaaaaaaaaaaaaaaaaaaa
Anyone can help me with this one? Thanks.
[c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char m[103], n[103], ml[2], nl[2], i;
int mlast, nlast, mlen, nlen;
int main(){
for (;;){
for (i=0; i<103; i++){
m='\0';
n='\0';
}
scanf("%s %s",m,n);
if ((m[0]=='0')&&(m[1]=='\0')&&(n[0]=='0')&&(n[1]=='\0')){
break;
}
mlen=strlen(m)-1;
nlen=strlen(n)-1;
ml[0]=m[mlen];
nl[0]=n[nlen];
mlast=atoi(ml);
nlast=atoi(nl);
if ((n[0]='0')&&(n[1]='\0')){
printf ("0\n");
}
else if (mlast==1){
printf ("1\n");
}
else if (mlast==2){
if (nlast%4==0){
printf("6\n");
}
else if (nlast%4==1){
printf("2\n");
}
else if (nlast%4==2){
printf("4\n");
}
else if (nlast%4==3){
printf("8\n");
}
}
else if (mlast==3){
if (nlast%4==0){
printf("1\n");
}
else if (nlast%4==1){
printf("3\n");
}
else if (nlast%4==2){
printf("9\n");
}
else if (nlast%4==3){
printf("7\n");
}
}
else if (mlast==4){
if (nlast%2==0){
printf("6\n");
}
else if (nlast%2==1){
printf("4\n");
}
}
else if (mlast==5){
printf("5\n");
}
else if (mlast==6){
printf("6\n");
}
else if (mlast==7){
if (nlast%4==0){
printf("1\n");
}
else if (nlast%4==1){
printf("7\n");
}
else if (nlast%4==2){
printf("9\n");
}
else if (nlast%4==3){
printf("3\n");
}
}
else if (mlast==8){
if (nlast%4==0){
printf("6\n");
}
else if (nlast%4==1){
printf("8\n");
}
else if (nlast%4==2){
printf("4\n");
}
else if (nlast%4==3){
printf("2\n");
}
}
else if (mlast==9){
if (nlast%2==0){
printf("1\n");
}
else if (nlast%2==1){
printf("9\n");
}
}
else if (mlast==0){
printf("0\n");
}
}
return 0;
}
[/c]
[c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char m[103], n[103], ml[2], nl[2], i;
int mlast, nlast, mlen, nlen;
int main(){
for (;;){
for (i=0; i<103; i++){
m='\0';
n='\0';
}
scanf("%s %s",m,n);
if ((m[0]=='0')&&(m[1]=='\0')&&(n[0]=='0')&&(n[1]=='\0')){
break;
}
mlen=strlen(m)-1;
nlen=strlen(n)-1;
ml[0]=m[mlen];
nl[0]=n[nlen];
mlast=atoi(ml);
nlast=atoi(nl);
if ((n[0]='0')&&(n[1]='\0')){
printf ("0\n");
}
else if (mlast==1){
printf ("1\n");
}
else if (mlast==2){
if (nlast%4==0){
printf("6\n");
}
else if (nlast%4==1){
printf("2\n");
}
else if (nlast%4==2){
printf("4\n");
}
else if (nlast%4==3){
printf("8\n");
}
}
else if (mlast==3){
if (nlast%4==0){
printf("1\n");
}
else if (nlast%4==1){
printf("3\n");
}
else if (nlast%4==2){
printf("9\n");
}
else if (nlast%4==3){
printf("7\n");
}
}
else if (mlast==4){
if (nlast%2==0){
printf("6\n");
}
else if (nlast%2==1){
printf("4\n");
}
}
else if (mlast==5){
printf("5\n");
}
else if (mlast==6){
printf("6\n");
}
else if (mlast==7){
if (nlast%4==0){
printf("1\n");
}
else if (nlast%4==1){
printf("7\n");
}
else if (nlast%4==2){
printf("9\n");
}
else if (nlast%4==3){
printf("3\n");
}
}
else if (mlast==8){
if (nlast%4==0){
printf("6\n");
}
else if (nlast%4==1){
printf("8\n");
}
else if (nlast%4==2){
printf("4\n");
}
else if (nlast%4==3){
printf("2\n");
}
}
else if (mlast==9){
if (nlast%2==0){
printf("1\n");
}
else if (nlast%2==1){
printf("9\n");
}
}
else if (mlast==0){
printf("0\n");
}
}
return 0;
}
[/c]
i don't know what's the probs here? i have tested many times but invain
can any body halp me on my code with some test data
[cpp]
arios
[/cpp]
can any body halp me on my code with some test data
[cpp]
arios
[/cpp]
Last edited by zubair on Mon Oct 27, 2003 2:10 pm, edited 1 time in total.
zubair-CUET old sailor
10515 why wrong ans plz help me
#include<stdio.h>
void main()
{
long int m,n; char c;
int l,p,a2[4]={6,2,4,8},a3[4]={1,3,9,7},a4[2]={6,4},a7[4]={1,7,9,3},a8[4]={6,8,4,2},a9[2]={1,9};
int mod2,mod4;
while(2)
{
while((c=getchar())!=' '&&c!='\n'&&c!='\t') m=c-48;
while((c=getchar())!=' '&&c!='\n'&&c!='\t') n=c-48;
if(m==0&&n==0)
break;
mod2=n%2;
mod4=n%4;
p=m%10;
if(n==0)
l=1;
else if(p==0||p==1||p==5||p==6)
l=p;
else if(p==2)
l=a2[mod4];
else if(p==3)
l=a3[mod4];
else if(p==4)
l=a4[mod2];
else if(p==7)
l=a7[mod4];
else if(p==8)
l=a8[mod4];
else if(p==9)
l=a9[mod2];
printf("%d\n",l);
}
}
void main()
{
long int m,n; char c;
int l,p,a2[4]={6,2,4,8},a3[4]={1,3,9,7},a4[2]={6,4},a7[4]={1,7,9,3},a8[4]={6,8,4,2},a9[2]={1,9};
int mod2,mod4;
while(2)
{
while((c=getchar())!=' '&&c!='\n'&&c!='\t') m=c-48;
while((c=getchar())!=' '&&c!='\n'&&c!='\t') n=c-48;
if(m==0&&n==0)
break;
mod2=n%2;
mod4=n%4;
p=m%10;
if(n==0)
l=1;
else if(p==0||p==1||p==5||p==6)
l=p;
else if(p==2)
l=a2[mod4];
else if(p==3)
l=a3[mod4];
else if(p==4)
l=a4[mod2];
else if(p==7)
l=a7[mod4];
else if(p==8)
l=a8[mod4];
else if(p==9)
l=a9[mod2];
printf("%d\n",l);
}
}
arahman
Dear bayzid
Input
Your output
Output should be
I think you should hold at least last 2 digit of n.
Your code
My code
i think you got that whatever i wanna say
Please remove your code from the forum
Good Luck!!!!
Input
Code: Select all
17 11
2 12
3 10
Code: Select all
7
4
1
Code: Select all
3
6
9
Your code
Code: Select all
m=7 & n=1;
1%4= 1;
For the m=7 & n=1
Result = 7.
Code: Select all
m=7 & n=11
11%4=3;
For m=7 & n=3
Result = 3.
Please remove your code from the forum
Good Luck!!!!
this time WA
what next...............?
what next...............?
help me about 10515 h to get input two digit of n at a time
help me how to get input two digit at a time in the below of code.
because input is 10^101.i think this is not possible to handle in array.
while((c=getchar())!=' '&&c!='\n'&&c!='\t') n=c-48;
because input is 10^101.i think this is not possible to handle in array.
while((c=getchar())!=' '&&c!='\n'&&c!='\t') n=c-48;
arahman