#include<bits/stdc++.h>
using namespace std;
long long read(){
long long ans=0,ch=getchar(),f=1;
while(!('0'<=ch&&ch<='9'))f=-1,ch=getchar();
while('0'<=ch&&ch<='9')ans=ans*10+ch-48,ch=getchar();
return ans*f;
}
void putt(long long x){
if(x>=10)putt(x/10);
putchar(x%10+'0');
}
void puttt(long long x){
if(x==0)putchar('0');
else if(x<0)putchar('-'),putt(-x);
if(x>0)putt(x);
}
int main(){
freopen("exfib.in","r",stdin);
freopen("exfib.out","w",stdout);
int T;
T=read();
while(T--){
long long a,b,k,q,p,f,t=0;
a=read();
b=read();
k=read();
p=read();
q=read();
if(b==0){
putchar('0');
putchar('\n');
continue;
}
if(b==1){
f=a*q+b*p;
t=f*p-q*q;
if(k%2==1)puttt(t);
else puttt(-t);
}
if(b==-1){
f=q*a+p*b;
t=f*p-q*q;
puttt(t);
}
putchar('\n');
}
return 0;
}
``` cpp
以上是考试代码
``` cpp
#include<bits/stdc++.h>
using namespace std;
long long read(){
long long ans=0,ch=getchar(),f=1;
while(!('0'<=ch&&ch<='9'))f=-1,ch=getchar();
while('0'<=ch&&ch<='9')ans=ans*10+ch-48,ch=getchar();
return ans*f;
}
void putt(long long x){
if(x>=10)putt(x/10);
putchar(x%10+'0');
}
void puttt(long long x){
if(x==0)putchar('0');
else if(x<0)putchar('-'),putt(-x);
if(x>0)putt(x);
}
int main(){
int T;
T=read();
while(T--){
long long a,b,k,q,p,f,t=0;
a=read();
b=read();
k=read();
p=read();
q=read();
if(b==0){
int x=a*q*p-q*q;
if(k==1) puttt(x);
else putchar('0');
}
if(b==1){
t=(a*q+b*p)*p-q*q;
if(k%2==1)puttt(t);
else puttt(-t);
}
if(b==-1){
t=(q*a+p*b)*p-q*q;
puttt(t);
}
putchar('\n');
}
return 0;
}
``` cpp
这个是订正赛的代码(人话,没有任何区别)
这错哪里了?(人抓狂ing)