//http://www.spoj.com/problems/SNGLOOP1/
here after solving the equation
#include<stdio.h>
int main(){
long long t,m,n,p;
scanf("%lld",&t);
while(t--){
scanf("%lld %lld",&n,&m);
p=(m-n)%4;
if(p==1)
printf("3\n");
else if(p==2)
printf("9\n");
else if(p==3)
printf("7\n");
else
printf("1\n");
}
return 0;
}
here after solving the equation
p=(10*m+15+4*Sm)/(10*n+15+4*Sn)
and for any m or n
p=3^(m-n)
#include<stdio.h>
int main(){
long long t,m,n,p;
scanf("%lld",&t);
while(t--){
scanf("%lld %lld",&n,&m);
p=(m-n)%4;
if(p==1)
printf("3\n");
else if(p==2)
printf("9\n");
else if(p==3)
printf("7\n");
else
printf("1\n");
}
return 0;
}
No comments:
Post a Comment