中级光能
今天无聊,就写了一道1分题5484
https://newcourse.codingtang.com/#/problem/problemSub?id=5484
就在刚才,我突发奇想,用了一堆头文件+高精度减法(本萌新还没学到高精度减法,所以上网找的,勿喷)
于是就这么愉快的CE了(c++编译通过了),CE代码如下:
#include<limits>
#include<list>
#include<iomanip>
#include<ios>
#include<iostream>
#include<istream>
#include<ostream>
#include<queue>
#include<set>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<cwchar>
#define N 1001
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize(2)
using namespace std;
int a[300],b[300],c[300];
string s1;
string s2;
int main()
{
cin>>s1;
int len1=s1.size();
cin>>s2;
int len2=s2.size();
if(len1<len2||(len1==len2&&s1<s2))
{
printf("-");
swap(s1,s2);
swap(len1,len2);
}
for(int i=1;i<=len1;i++) a[i]=s1[len1-i]-'0';
for(int i=1;i<=len2;i++) b[i]=s2[len2-i]-'0';
int len=max(len1,len2);
for(int i=1;i<=len;i++)
{
if(a[i]<b[i])
{
a[i+1]--;
a[i]+=10;
}
c[i]=a[i]-b[i];
}
while(c[len]==0&&len>=2) len--;
for(int i=len;i>=1;i--) printf("%d",c[i]);
return 0;
}
请问各位大佬,这代码到底错在哪里?
刘承志在2020-10-08 13:38:33追加了内容
感兴趣的大佬可以把我这代码提交一下,其后果本人不承担
初级守护
你作死作的太溜了!
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<a-b;
return 0;
}
中级光能
@沙宸安
devc++里的显示:
编译单个文件...
--------
- 文件名: C:\Users\chenting\Documents\未命名7.cpp
- 编译器名: TDM-GCC 4.9.2 64-bit Release
处理 C++ 源文件...
--------
- C++ 编译器: C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\g++.exe
- 命令: g++.exe "C:\Users\chenting\Documents\未命名7.cpp" -o "C:\Users\chenting\Documents\未命名7.exe" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++" -L"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib" -L"C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib" -static-libgcc
编译结果...
--------
- 错误: 0
- 警告: 0
- 输出文件名: C:\Users\chenting\Documents\未命名7.exe
- 输出大小: 1.83725643157959 MiB
- 编译时间: 1.02s
酷町堂网站里的显示:
Compile Error:0分代码共享
刘承志的测评结果:
main.cpp: In function 'int main()':
main.cpp:77:13: error: 'printf' was not declared in this scope
printf("-");
^
main.cpp:94:42: error: 'printf' was not declared in this scope
for(int i=len;i>=1;i--) printf("%d",c[i]);
^
中级光能
各位,因为头文件太多,导致忘了加cstdio
现在这代码它AC了!!!!!
#include<limits>
#include<list>
#include<cstdio>
#include<iomanip>
#include<ios>
#include<iostream>
#include<istream>
#include<ostream>
#include<queue>
#include<set>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<cwchar>
#define N 1001
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize(2)
using namespace std;
int a[300],b[300],c[300];
string s1;
string s2;
int main()
{
cin>>s1;
int len1=s1.size();
cin>>s2;
int len2=s2.size();
if(len1<len2||(len1==len2&&s1<s2))
{
printf("-");
swap(s1,s2);
swap(len1,len2);
}
for(int i=1;i<=len1;i++) a[i]=s1[len1-i]-'0';
for(int i=1;i<=len2;i++) b[i]=s2[len2-i]-'0';
int len=max(len1,len2);
for(int i=1;i<=len;i++)
{
if(a[i]<b[i])
{
a[i+1]--;
a[i]+=10;
}
c[i]=a[i]-b[i];
}
while(c[len]==0&&len>=2) len--;
for(int i=len;i>=1;i--) printf("%d",c[i]);
return 0;
}