救命!考试测4分,定正赛测88分!求教教错哪里了
  • 板块题目总版
  • 楼主wudaojiushu
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/4/5 21:16
  • 上次更新2024/4/5 23:56:02
查看原帖
救命!考试测4分,定正赛测88分!求教教错哪里了
725268
wudaojiushu楼主2024/4/5 21:16
//exfib
#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(){
//	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){
			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)
2024/4/5 21:16
加载中...