3 条题解
-
0端木俁 (房佳坤) LV 10 @ 2021-03-09 21:13:05
#include<bits/stdc++.h> using namespace std; vector <int> a; int main() { int t,n;cin>>t>>n; for(int i=t;i<=n;i++) a.push_back(i); int sum=0; for(int i=0;i<a.size();i++) sum+=a[i]; cout<<sum; return 0; }
-
02021-02-27 14:41:48@
#include <iostream>
using namespace std;int Sum(int xmin,int xmax);
// Sum(1,100)= Sum(1,99)+100
// = Sum(1,98)+99 +100
// = Sum(1,1)+2.....+99 +100int main()
{
int x,y;
cin>>x>>y;
cout<<Sum(x,y)<<endl;return 0;
}
int Sum(int xmin,int xmax)
{if(xmin==xmax)
return xmax;
int sum=Sum(xmin, xmax-1);
return xmax+sum;
} -
-22021-03-20 22:08:50@
#include <iostream>
using namespace std;int Sum(int xmin,int xmax);
// Sum(1,100)= Sum(1,99)+100
// = Sum(1,98)+99 +100
// = Sum(1,1)+2.....+99 +100int main()
{
int x,y;
cin>>x>>y;
cout<<Sum(x,y)<<endl;return 0;
}
int Sum(int xmin,int xmax)
{if(xmin==xmax)
return xmax;
int sum=Sum(xmin, xmax-1);
return xmax+sum;
}
- 1
信息
- ID
- 1090
- 难度
- 3
- 分类
- (无)
- 标签
- 递交数
- 274
- 已通过
- 128
- 通过率
- 47%
- 被复制
- 9
- 上传者