一个报错
Windows PowerShell版权所有 (C) Microsoft Corporation。保留所有权利。
尝试新的跨平台 PowerShell https://aka.ms/pscore6
PS D:\editor\code> cd "d:\editor\code\" ; if ($?) { g++ test.cpp -o test } ; if ($?) { .\test }
C:\Users\Lenovo\AppData\Local\Temp\ccHnlDAy.s: Assembler messages:
C:\Users\Lenovo\AppData\Local\Temp\ccHnlDAy.s:147: Error: value of 000000013e657db6 too large for field of 4 bytes at 0000000000000066
C:\Users\Lenovo\AppData\Local\Temp\ccHnlDAy.s:148: Error: value of 000000012173896d too large for field of 4 bytes at 000000000000006d
C:\Users\Lenovo\AppData\Local\Temp\ccHnlDAy.s:149: Error: value of 000000013e657dd4 too large for field of 4 bytes at 0000000000000074
C:\Users\Lenovo\AppData\Local\Temp\ccHnlDAy.s:169: Error: value of 000000013e657e16 too large for field of 4 bytes at 00000000000000c6
C:\Users\Lenovo\AppData\Local\Temp\ccHnlDAy.s:171: Error: value of 000000013e657e3f too large for field of 4 bytes at 00000000000000cc
C:\Users\Lenovo\AppData\Local\Temp\ccHnlDAy.s:188: Error: value of 000000013e657e7d too large for field of 4 bytes at 0000000000000115
C:\Users\Lenovo\AppData\Local\Temp\ccHnlDAy.s:189: Error: value of 000000013e657e3c too large for field of 4 bytes at 000000000000011c
C:\Users\Lenovo\AppData\Local\Temp\ccHnlDAy.s:190: Error: value of 000000013e657e4b too large for field of 4 bytes at 0000000000000123
C:\Users\Lenovo\AppData\Local\Temp\ccHnlDAy.s:202: Error: value of 000000013e657ea2 too large for field of 4 bytes at 0000000000000152
大佬们,这个报错问题是出在哪,也不提示是哪行代码有问题,能解决吗 所以你代码呢 南归 发表于 2021-8-3 21:17
所以你代码呢
代码过于长了,而且这个报错并没有指明是在代码的哪个位置,应该与语法没啥关系 一世轻尘 发表于 2021-8-3 22:50
代码过于长了,而且这个报错并没有指明是在代码的哪个位置,应该与语法没啥关系
与语法没关系,那与什么有关系?编译器?也就是说换一个编译器这个代码就可以用了?
因为编译器读取源代码,然后生成可执行程序,既然没有生成可执行程序,而且代码又没有问题,那么就是编译器的问题了?对吧?
发代码
本帖最后由 一世轻尘 于 2021-8-4 17:44 编辑
人造人 发表于 2021-8-3 23:31
与语法没关系,那与什么有关系?编译器?也就是说换一个编译器这个代码就可以用了?
因为编译器读取源代 ...
这是数学建模国赛一等奖的代码,太复杂了,看懂估计要花费很长时间,代码的思路没有问题,而且作者在比赛的时候确实跑出了正确的结果,正常报错的话,会提示是在代码哪一行出的问题,这个报错确实应该跟源代码没啥关系,处理过类似问题的人应该能很快知道是在哪里有问题
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
struct sta
{
short d, i, w, f;
sta(short _d = 0, short _i = 0, short _w = 0, short _f = 0)
{
d = _d, i = _i, w = _w, f = _f;
}
bool check()
{
return !d && !i && !w && !f;
}
void Print()
{
printf("%d %d %d %d\n", d, i, w, f);
}
};
const int D = 30;
const int N = 64;
const int W = 400;
const int F = 600;
const int Heavy = 1200;
const int start_money = 10000;
int n, m, dis;
short dp;
sta last;
bool vis;
vector<int> q;
int weather;
queue<sta> que;
int l, r;
void bfs()
{
for (int w = 0; w <= W; w++)
for (int f = 0; 3 * w + 2 * f <= Heavy && 5 * w + 10 * f <= start_money && f <= F; f++)
{
dp = start_money - 5 * w - 10 * f;
que.push(sta(0, 1, w, f));
//sta(0,1,w,f).Print();
vis = 1;
r++;
}
while (!que.empty())
{
//printf("%.8f\n",1.0*l/(1ll*D*W*F*W*F));
sta now = que.front();
que.pop();
//now.Print();
int cw = 0, cf = 0, d = now.d, i = now.i, w = now.w, f = now.f, k;
vis = 0;
if (d + 1 > D)
continue;
if (i == 64)
continue;
switch (weather)
{
case 1:
{
cw = 5, cf = 7;
break;
}
case 2:
{
cw = 8, cf = 6;
break;
}
case 3:
{
cw = 10, cf = 10;
break;
}
}
if ((i == 30 || i == 55) && w >= 3 * cw && f >= 3 * cf && dp < dp + 1000)
{
dp = dp + 1000;
last = sta(d, i, w, f);
if (!vis)
{
vis = 1;
que.push(sta(d + 1, i, w - 3 * cw, f - 3 * cf));
//sta(d+1,i,w-3*cw,f-3*cf).Print();
r++;
}
}
if (weather != 3 && w >= 2 * cw && f >= 2 * cf)
{
for (auto u : q)
if (dp < dp)
{
dp = dp;
last = sta(d, i, w, f);
if (!vis)
{
vis = 1;
que.push(sta(d + 1, u, w - 2 * cw, f - 2 * cf));
//sta(d+1,u,w-2*cw,f-2*cf).Print();
r++;
}
}
}
if (i == 39 || i == 62)
{
for (int w1 = 0; w1 * 3 <= Heavy - w * 3 - f * 2 && w1 * 10 <= dp && w1 + w <= W; w1++)
for (int
f1 = 0;
(w1 + w) * 3 + (f1 + f) * 2 <= Heavy && w1 * 10 + f1 * 20 <= dp && f1 + f <= F; f1++)
if (dp < dp - (w1 * 10 + f1 * 20))
{
dp = dp - (w1 * 10 + f1 * 20);
last = sta(d, i, w, f);
if (!vis)
{
vis = 1;
que.push(sta(d, i, w + w1, f + f1));
//sta(d,i,w+w1,f+f1).Print();
r++;
}
}
}
if (w >= cw && f >= cf && dp < dp)
{
dp = dp;
last = sta(d, i, w, f);
if (!vis)
{
vis = 1;
que.push(sta(d + 1, i, w - cw, f - cf));
//sta(d+1,i,w-cw,f-cf).Print();
r++;
}
}
}
}
void getans(int d, int i, int w, int f)
{
sta u = last;
if (!u.check())
getans(u.d, u.i, u.w, u.f);
printf("%d %d %d %d\n", d, i, w, f);
}
int main()
{
cin >> n >> m;
memset(dp, -1, sizeof(dp));
for (int a, b, i = 1; i <= m; i++)
{
cin >> a >> b;
dis = 1, q.push_back(b);
}
for (int i = 1; i <= 30; i++)
cin >> weather;
bfs();
int T = 64;
sta ans(0, T, 0, 0);
double aaans = 0;
for (int d = 0; d <= 30; d++)
for (int w = 0; w <= W; w++)
for (int f = 0; f <= F; f++)
if (dp != -1 && 1.0 * dp + w * 2.5 + f * 5 > 1.0 * dp + ans.w * 2.5 + ans.f * 5)
ans = sta(d, T, w, f), aaans = 1.0 * dp + w * 2.5 + f * 5;
cout << aaans << "\n";
for (int d = 0; d <= 30; d++)
for (int w = 0; w <= W; w++)
for (int f = 0; f <= F; f++)
if ((int)(1.0 * dp + ans.w * 2.5 + ans.f * 5) == aaans)
{
getans(d, T, w, f);
puts("==================");
}
return 0;
} 一世轻尘 发表于 2021-8-4 17:42
这是数学建模国赛一等奖的代码,太复杂了,看懂估计要花费很长时间,代码的思路没有问题,而且作者在比赛的 ...
不发代码,怎么可能知道发生了什么?
g++ -g -Wall -mcmodel=medium -o main main.cpp
https://blog.csdn.net/www_helloworld_com/article/details/88964968
页:
[1]