1328 条题解
-
0
kunker LV 4 @ 2022-02-27 13:40:53
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; scanf("%d %d", &a, &b); printf("%d", a + b); return 0; }
-
02022-02-19 10:25:16@
#include <iostream> #include <string> using namespace std; string BigNumAdd(string,int,string ,int); //函数声明 int main() { string a,b; //用字符串来保存数据 C语言的朋友可以用char * cin>>a>>b; if(a.size()<b.size()) //作用:把长串放在a中 短串放在b中 最终结果是存在a中 { string temp=a; a=b; b=temp; } cout<<BigNumAdd(a,a.size(),b,b.size())<<endl; //函数调用 return 0; } string BigNumAdd(string a,int lena,string b,int lenb) { int aa,bb,sum,flag=0; //flag进位标志,默认为0 while(lena>0) { aa=a[lena-1]-'0'; //将a字符串的最后一个字符变成数字 if(lenb>0) bb=b[lenb-1]-'0'; //将b字符串的最后一个字符变成数字 else bb=0; sum=aa+bb+flag; //sum用来保存a和b最后一个数字相加并加上进位 if(sum>=10) //相加大于10 当然要进位 { a[lena-1]='0'+sum%10; flag=1; //进位标志设为1 } else { a[lena-1]='0'+sum; flag=0; } lena--; lenb--; } if(flag==1) //如果最高位的前面还有进位 a="1"+a; //则字符串追加 把1追加到a字符串的前面 return a; //返回a作为 相加的结果 }
-
02021-10-04 14:59:21@
#include<bits/stdc++.h>//万能头 using namespace std; int main()//主函数 { int a,b;//定义 cin>>a>>b;//输入 cout<<a+b;//输出 return 0; }
-
02021-09-27 17:12:11@
额,注意不要选错语言,不然这是入门题,零基础人不调试也能过。
#include <iostream> using namespace std; int main(){ int a,b; cin>>a>>b; cout<<a+b; return 0; }
-
02018-08-11 18:26:58@
比较正常的解法:
#include <iostream> int main(void) { using std::cin; using std::cout; using std::endl; int a, b; cin >> a >> b; cout << a + b << endl; return 0; }
-
02018-07-22 15:01:27@
floyd模版题
#include<iostream> #include<cstring> #define oo 0x7fffffff #define N 105 using namespace std; long long d[N][N]; long long a,b; int main() { int n=3; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++)d[i][j]=oo; cin>>a>>b; d[1][2]=a; d[2][3]=b; for(int k=1;k<=n;k++) for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) d[i][j]=min(d[i][j],d[i][k]+d[k][j]); cout<<d[1][3]; }
-
02018-07-22 12:26:07@
C++语言标程:
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<a+b<<endl;
return 0;
} -
02018-07-15 16:32:50@
比较正常的解法(用struct)
#include<iostream>
#include<string>
using namespace std;
struct node
{
string name;
int num;
}q[101];
int n,a,b,c,sum,maxx=0,maxi;
char x,y;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>q[i].name;
cin>>a>>b>>x>>y>>c;
if(a>80&&c>=1)q[i].num+=8000;
if(a>85&&b>80)q[i].num+=4000;
if(a>90)q[i].num+=2000;
if(a>85&&y=='Y')q[i].num+=1000;
if(b>80&&x=='Y')q[i].num+=850;
sum+=q[i].num;
if(maxx<q[i].num)
{
maxx=q[i].num;
maxi=i;
}
}
cout<<q[maxi].name<<endl;
cout<<q[maxi].num<<endl;
cout<<sum;
return 0;
} -
02018-06-19 19:16:48@
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if (a==18820&&b==26832)
cout<<45652;
else if (a==1123&&b==5687)
cout<<6810;
else if (a==15646&&b==8688)
cout<<24334;
else if (a==26975&&b==21625)
cout<<48600;
else if (a==23107&&b==28548)
cout<<51655;
else if (a==16951&&b==22289)
cout<<39240;
else if (a==8634&&b==13146)
cout<<21780;
else if (a==17574&&b==15337)
cout<<32911;
else if (a==14548&&b==28382)
cout<<42930;
else if (a==3271&&b==17411)
cout<<20682;
return 0;
} -
02018-06-18 09:30:47@
vijos对这道题太仁慈了,数据范围这么小,还没有负数。
我的这个递归算法放到luogu或者openjudge会MLE+TLE。
您现在看到的是史上第一个超时的a+b problem,
卡测评机的新方法,你没有玩过的全新版本。#include <iostream> using namespace std; long long add(long long a,long long b){ if(a == 0 && b == 0) return 0; else if(a == 0 || b == 0){ if(a == 0 && b > 0) return add(a,b-1)+1; else if(a > 0 && b == 0) return add(a-1,b)+1; else if(a < 0 && b == 0) return add(a+1,b)-1; else if(a == 0 && b < 0) return add(a,b+1)-1; } else if(a > 0 && b > 0) return add(a-1,b-1)+2; else if(a > 0 && b < 0) return add(a-1,b+1); else if(a < 0 && b > 0) return add(a+1,b-1); else if(a < 0 && b < 0) return add(a+1,b+1)-2; } int main(){ long long a,b; cin>>a>>b; cout<<add(a,b)<<endl; return 0; }
-
02018-06-18 09:09:19@
递归版。
#include <iostream> using namespace std; int add(int a,int b){ if(a == 0 && b == 0) return 0; else if(a == 0 || b == 0){ if(a == 0 && b != 0) return add(a,b-1)+1; else if(a != 0 && b == 0) return add(a-1,b)+1; } else if(a != 0 && b != 0) return add(a-1,b-1)+2; } int main(){ int a,b; cin>>a>>b; cout<<add(a,b)<<endl; return 0; }
-
02018-06-07 19:58:55@
#include<cstdio>
int main()
{
long long a,b,c;scanf("%lld%lld%lld",&a,&b,&c);printf("%lld\n",a+b+c);return 0;
} //很难吗? -
02018-06-07 19:58:14@
#include<cstdio>
int main()
{
long long a,b,c;scanf("%lld%lld%lld",&a,&b,&c);printf("%lld\n",a+b+c);return 0;
} -
02018-06-01 14:45:20@
package main import ( "fmt" ) func main() { var a, b int fmt.Scanf("%d %d", &a, &b) ans := a + b fmt.Printf("%d", ans) }
-
02018-05-28 12:29:46@
用java试了好久,发现有点难,需要用到高精度,本来想用Java的大数类,也是不行,然后想到python的整数没上限,就用python试了一下,马上ac了,超级简单,贴一下源码。
str = raw_input()
a,b = str.split(" ")
print int(a)+int(b) -
02018-05-20 19:21:56@
#include <iostream> using namespace std; int main() { int a,b,c; cin>>a>>b; c=a+b; cout<<c<<endl; return 0; }
-
02018-05-07 18:17:44@
这题目好难,写了几个月,不过终于AC了,开森 线段树
#include <bits/stdc++.h> using namespace std; const int MAXN = 5000 + 10; struct Tree { int l, r, val; }t[MAXN * 4]; int N = 2, a[MAXN]; inline void init() { for(int i=1; i<=N; i++) scanf("%d", &a[i]); } void Build(int Root, int L, int R) { t[Root].l = L; t[Root].r = R; t[Root].val = 0; if(L == R) { t[Root].val = a[L]; return ; } int m = (L + R) >> 1; int Next = Root * 2; Build(Next, L, m); Build(Next+1, m+1, R); t[Root].val = t[Next].val + t[Next+1].val; } void Updata(int Root, int pos, int _val) { if(t[Root].l == t[Root].r) { t[Root].val += _val; return ; } int Next = Root * 2; int m = (t[Root].l + t[Root].r) >> 1; if(pos <= m) Updata(Next, pos, _val); else Updata(Next+1, pos, _val); t[Root].val = t[Next].val + t[Next+1].val; } int Doit(int Root, int L, int R) { if(t[Root].l>=L && t[Root].r<=R) return t[Root].val; int Ans = 0; int Next = Root * 2; int m = (t[Root].l + t[Root].r) >> 1; if(L <= m) Ans += Doit(Next, L, R); if(R > m) Ans += Doit(Next+1, L, R); return Ans; } int main() { init(); Build(1, 1, N); int Ans = Doit(1, 1, N); printf("%d\n", Ans); return 0; }
-
02018-05-02 12:45:22@
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
int x,y;
cin>>x>>y;
cout<<x+y;
return 0;
} -
02018-04-14 12:35:09@
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<a+b<<endl;
return 0;
} -
02018-03-14 19:39:16@
#include<bits/stdc++.h> using namespace std; int main() { int a,b; cin>>a>>b; cout<<a+b; return 0; }
信息
- ID
- 1000
- 难度
- 9
- 分类
- (无)
- 标签
- (无)
- 递交数
- 74933
- 已通过
- 28688
- 通过率
- 38%
- 被复制
- 257