I am getting wrong answer in http://www.spoj.com/problems/FIBFUNCH/ Please somebody help.
include<stdio.h>
int main() { long long int t,n,x,y,s=0,m,i=0; scanf("%lld",&t); while(t--) {s=0; scanf("%lld%lld%lld%lld",&x,&y,&n,&m); s=(x%m+y%m)%m; for(i=2;i<n;i++) { y=x+y; x=y-x; s+=(y%m); s%=m; } printf("%lld\n",s); } return 0; }
Sorry, but nobody there want to read ur code and try to find a mistake. Better if u will show to us the idea of ur solution. After that, may be, someone will ask to u :)