缔造者之神
@刘乐宸
恶搞1061:
#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)
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
char a1[100],b1[100];
int a[100],b[100],c[100],lena,lenb,lenc,i,x;
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));//清空
gets(a1);
gets(b1);//字符数组读入,此乃高精度加法,算最简单的一个
lena=strlen(a1);
lenb=strlen(b1);
for(int i=0;i<=lena-1;i++) a[lena-i]=a1[i]-48;
for(int i=0;i<=lenb-1;i++) b[lenb-i]=b1[i]-48;//将加数放入int数组当中
lenc=1;
x=0;
while(lenc<=lena||lenc<=lenb)
{
c[lenc]=a[lenc]+b[lenc]+x;//两个数加起来
x=c[lenc]/10;
c[lenc]%=10;
lenc++;
}
c[lenc]=x;
if(c[lenc]==0) lenc--;
for(int i=lenc;i>=1;i--) cout<<c[i];
cout<<endl;//好习惯
return 0;//保险起见
}
恶搞5484:
#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)
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int a[100],b[100],c[100],lena,lenb,lenc,i;
char n[100],n1[100],n2[100];
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));
gets(n1);
gets(n2);//不多讲
if(strlen(n1)<strlen(n2)||(strlen(n1)==strlen(n2)&&strcmp(n1,n2)<0))//处理被减数和减数,交换它们(其实就是判断谁大)
{
strcpy(n,n1);
strcpy(n1,n2);
strcpy(n2,n);
cout<<"-";//被减数没减数大,肯定是负数啦!
}
lena=strlen(n1);
lenb=strlen(n2);
for(int i=0;i<=lena-1;i++) a[lena-i]=(int)(n1[i]-48);
for(int i=0;i<=lenb-1;i++) b[lenb-i]=(int)(n2[i]-48);//真规整啊!
i=1;
while(i<=lena||i<=lenb)
{
if(a[i]<b[i])
{
a[i]+=10;
a[i+1]--;//向高位借一当十(还不还?)
}
c[i]=a[i]-b[i];
i++;
}
lenc=i;
while((c[lenc]==0)&&(lenc>1)) lenc--;//删除前导0
for(int i=lenc;i>=1;i--) cout<<c[i];
cout<<endl;
return 0;//好习惯
}
大家一起恶搞吧!(更多恶搞可以发在下面)
(看一下豆子数量:111)
王文博在2021-08-07 13:07:41追加了内容
错的也有可能
王文博在2021-08-07 13:09:21追加了内容
有一个问题:输入数组必须换行,否则会读入失败,所以不适合于这些空格隔开的题目。
王文博在2021-08-12 08:00:15追加了内容
1
修练者
告诉你们一个有用的方法按Ctrl+p就可以复制代码了
一起恶搞2085
- #include<bits/stdc++.h>
- using namespace std;
- int di[13]={0,-2,-2,-1,-1,1,1,2,2,-2,-2,2,2},dj[13]={0,1,-1,2,-2,2,-2,1,-1,2,-2,2,-2}; int c[105][105]; bool f[105][105]; int bfs(int x, int y){
- queue<int>qx, qy;
- qx.push(x),qy.push(y);
- memset(c,0,sizeof(c));
- memset(f,0,sizeof(f));
- f[x][y]=1,c[x][y]=0;
- if(x==1&&y==1)
- return 0;
- while(!qx.empty()){
- for(int i=1;i<=12;i++) {
- int a=qx.front()+di[i], b=qy.front()+dj[i];
- if(a>=1&&b>=1&&a<=100&&b<=100&&f[a][b]==0){
- if(a==1&&b==1) return c[qx.front()][qy.front()]+1;
- qx.push(a),qy.push(b);
- f[a][b]=1;
- c[a][b]=c[qx.front()][qy.front()]+1;
- }
- int a=qx.front()+di[i], b=qy.front()+dj[i];
- }
- qx.pop(),qy.pop();
- for(int i=1;i<=12;i++) {
- }
- }
- int main(){
- int n1, n2, m1, m2;
- cin>>n1>>m1>>n2>>m2;
- cout<<bfs(n1, m1)<<endl;
- cout<<bfs(n2, m2);
- return 0;
- }
初级天翼
恶搞2728:
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
string a,b;
long long xa[100000]={},xb[100000]={},tot[100000]={};
cin>>a>>b;
for(int i=0;i<a.length();i++)
xa[i]=a[a.length()-i-1]-'0';
for(int i=0;i<b.length();i++)
xb[i]=b[b.length()-i-1]-'0';
int len=max(a.length(),b.length());
for(int i=0;i<len;i++)
tot[i]=xa[i]+xb[i];
for(int i=0;i<len;i++)
{
tot[i+1]+=tot[i]/10;
tot[i]%=10;
}
if(tot[len]) cout<<tot[len];
for(int i=len-1;i>=0;i--)
cout<<tot[i];
cout<<endl;
return 0;
}
新手启示者
代码:【dijkstra算法】
#include<bits/stdc++.h>
using namespace std;
struct node{
int next;
int w;
};
vector<node> g[105];
int dis[105],u[15],v[15],w[15];
bool found[105];
char a[15]={' ','H','e','l','l','o',',',' ','W','o','r','l','d','!'};
void dijkstra(int s){
memset(dis,0x3f,sizeof(dis));
memset(found,false,sizeof(found));
dis[s]=0;
while(1){
int u=-1;
for(int i=1;i<=13;i++){
if(!found[i]&(u==-1||dis[i]<dis[u])){
u=i;
}
}
if(u==-1)return ;
found[u]=1;
cout<<a[u];
for(int i=0;i<g[u].size();i++){
node e=g[u][i];
dis[e.next]=min(dis[e.next],dis[u]+e.w);
}
}
}
int main(){
for(int i=1;i<=12;i++){
u[i]=i,v[i]=i+1,w[i]=i;
}
for(int i=1;i<=13;i++){
g[u[i]].push_back((node){v[i],w[i]});
}
dijkstra(1);
return 0;
}
恶搞1000
包思远在2022-07-23 20:29:15追加了内容
@王文博
包思远在2022-07-24 18:08:56追加了内容
#include<bits/stdc++.h>
using namespace std;
char a[15]={' ','H','e','l','l','o',',',' ','W','o','r','l','d','!'};
int u[15],v[15],w[15],f[15][15],g[15][15];
void dfs(int l,int r){
if(g[l][r]==0x3f3f3f3f){
cout<<a[l];
return ;
}
dfs(l,g[l][r]);
dfs(g[l][r],r);
}
int main(){
for(int i=1;i<=12;i++){
u[i]=i,v[i]=i+1,w[i]=i;
}
memset(f,0x3f,sizeof(f));
memset(g,0x3f,sizeof(g));
for(int i=1;i<=12;i++){
f[u[i]][v[i]]=w[i];
}
for(int i=1;i<=13;i++){
for(int j=1;j<=13;j++){
for(int k=1;k<=13;k++){
if((f[i][k]+f[k][j])<f[i][j]){
f[i][j]=f[i][k]+f[k][j];
g[i][j]=k;
}
}
}
}
dfs(1,13);
cout<<a[13];
return 0;
}
还有
#include<bits/stdc++.h>
using namespace std;
int n,m,cnt,k,ans,fa[1005],u[15],v[15],w[15];
char c[15]={' ','H','e','l','l','o',',',' ','W','o','r','l','d','!'};
struct node{
int u,v,w;
}a[10005];
bool cmp(node x,node y){
return x.w<y.w;
}
void init(){
for(int i=1;i<=13;i++){
fa[i]=i;
}
}
int find(int x){
if(x==fa[x])return x;
return fa[x]=find(fa[x]);
}
void unite(int x,int y){
x=find(x);
y=find(y);
if(x==y)return ;
fa[x]=y;
}
bool same(int x,int y){
return find(x)==find(y);
}
int main(){
for(int i=1;i<=13;i++){
u[i]=i,v[i]=i+1,w[i]=i;
}
for(int i=1;i<=13;i++){
a[i].u=u[i],a[i].v=v[i],a[i].w=w[i];
}
init();
sort(a+1,a+1+13,cmp);
for(int i=1;i<=13;i++){
if(!same(a[i].u,a[i].v)){
ans+=a[i].w;
unite(a[i].u,a[i].v);
cnt++;
cout<<c[i];
}
}
return 0;
}
包思远在2022-07-24 18:10:09追加了内容
@王文博 @王文博 @王文博
初级天翼
恶搞1000
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
#define x "Hello, World!";
int main(){
string s1=x;
string s2=x;
string s3=x;
string s4=x;
string s5=x;
string s6=x;
string s7=x;
string s8=x;
string s9=x;
string s10=x;
cout<<s10;
return 0;
}
新手启示者
恶搞4410:
#include <algorithm>
using namespace std;
const int MAXN=100005;
int A[MAXN],B[MAXN],C[MAXN],ANS[MAXN],LEN_A,LEN_B,LEN_ANS;
void Read(int *A,int &LEN){
string cur;
cin>>cur;
LEN=cur.length();
for(int i=0;i<LEN;i++){
A[i]=cur[i]-48;
}
reverse(A,A+LEN);
}
int main(){
Read(A,LEN_A);
Read(B,LEN_B);
LEN_ANS=max(LEN_A,LEN_B);
for(int i=0;i<=LEN_ANS;i++){
ANS[i]=A[i]-B[i]-C[i];
if(ANS[i]<0){
C[i+1]++,ANS[i]+=10;
}
}
while(ANS[LEN_ANS]>1&&ANS[LEN_ANS-1]==0){
LEN_ANS--;
}
for(int i=LEN_ANS-1;i>=0;i--){
cout<<ANS[i];
}
return 0;
}