这个代码在g++ a.cpp -o a的命令行下输出很正常,但在加了-O2后全都输出了1。并且如果将里面的#define int __int128改成#define int long long后又没有问题了。 请问为什么呢,谢谢。
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define int __int128
#define ll long long
typedef pair<int, int> pii;
int a[15], tot;
int rd() {
char ch= getchar();
int t= 0;
while(ch< '0'|| ch> '9') ch= getchar();
while(ch>= '0'&& ch<= '9') t= (t<< 3)+ (t<< 1)+ ch- '0', ch= getchar();
return t;
}
void div(int x) {
for(int i= 2; i* i<= x; i++ ) {
if(x% i== 0) {
a[++ tot]= 1;
while(x% i== 0) a[tot]*= i, x/= i;
cout<<(long long)a[tot]<<endl;
cout<< endl;
}
}
}
signed main() {
int T= rd(), mod= rd();
div(mod);
return 0;
}