跳到正文

个人记录

【专栏保存版 #1】

mofan101028约 4 分钟
原文

这是 2025年12月29日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

收录
2025年12月29日
更新
2026年1月1日
篇幅
约 4 分钟

版本

  1. v3当前
  2. v2
  3. v1

为什么会出现不同的情况 创建者

mofan101028 发帖时间 2025-12-27 21:41:58 所属板块 学术版 回复举报删除 编辑回复

mofan101028 发表于 2025-12-27 21:41 回复楼主 我的代码在洛谷IDE下可以正常运行,但是我的代码在我自己的电脑下运行会return 3221225725,且不输出。

代码如下:

C++
#include <bits/stdc++.h>
using namespace std;
#define upp(x,y,z) for(x=(y);x<=(z);++x)
#define low(x,y,z) for(x=(y);x>=(z);--x)
#define tt template<typename t0>
#define fs(x) fixed<<setprecision(x)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define debug(x) cout<<"Line "<<__LINE__<<","<<(x)<<"."<<endl
tt inline void chkmax(t0 &x,t0 y){if(x<y){x=y;}}
tt inline void chkmin(t0 &x,t0 y){if(x>y){x=y;}}
const int eps=0xf; const int inf=0x7fffffff; const ll infll=0x7fffffffffffffff; const ull infull=0xffffffffffffffff;
const int N=1e6+eps; const ll mod=1e9+7;
void code(); void perf();
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); code(); //perf();
	return 0;
}
bool memorybegin;
ll qpow(ll x,ll y){ll res=1; while(y){if(y&1){res=res*x%mod;} x=x*x%mod; y>>=1;} return res;}
void code(){
	//freopen("prepow.out","w",stdout);
	ll pwo2[N]; pwo2[0]=1ll; int i;
	upp(i,1,1145){pwo2[i]=pwo2[i-1]*2ll%(mod-1ll); cout<<qpow(2ll,pwo2[i])<<endl;}
}
bool memoryend;
void perf(){
	cout<<"CPU time used:"<<fs(3)<<(double)clock()/CLOCKS_PER_SEC<<"s."<<endl;
	cout<<"Memory used:"<<fs(3)<<abs((&memoryend-&memorybegin)*1.0/1024.0/1024.0)<<"MB."<<endl;
} 

求问代码运行为什么会出现不同的情况,我猜可能是编译器问题,但是我其他的代码不会出现这样的情况。

3 条回复 默认排序

mofan101028 回复于 2 天前 举报 删除 回复 上面代码无用的地方有点多,简写一下:

C++
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6+0xf; const ll mod=1e9+7;
ll qpow(ll x,ll y){ll res=1; while(y){if(y&1){res=res*x%mod;} x=x*x%mod; y>>=1;} return res;}
int main(){
	ll pwo2[N]; pwo2[0]=1ll; int i;
	for(i=1;i<=1145;i++){pwo2[i]=pwo2[i-1]*2ll%(mod-1ll); cout<<qpow(2ll,pwo2[i])<<endl;}
	return 0;
}

展开

mofan101028 回复于 2 天前 举报 删除 回复 上述两个代码等价。

mofan101028 回复于 2 天前 举报 删除 回复 栈空间Windows默认1MB,Linux默认8MB,此贴结。