主站
DreamJudge
院校信息
专业题库
模拟考试
机试真题
专业课程
讨论区
兑换中心
登录
注册
发布
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
我与代码的故事
2024年4月21日 00:02
求1到n的和 (等差数列)题解:
P1133
回复 0
|
赞 1
|
浏览 125
#include<bits/stdc++.h> using namespace std; typedef long long LL; int n; LL ans; int main() { cin >> n; ans = n * (1 + n) / 2; cout << ans; return 0; }
小酒
2024年3月11日 15:50
求1到n的和 题解:
P1133
回复 0
|
赞 0
|
浏览 217
1133解题思路 #include <stdio.h> int main() { double n; scanf("%lf",&n); printf("%g",n*(n+1)/2); }
promising
2024年3月3日 20:43
求1到n的和 题解:
P1133
回复 0
|
赞 0
|
浏览 361
#include<stdio.h> int main() { int n; scanf("%d",&n); int sum=0; for(int i=1;i<=n;i++) { sum=sum+i; } &nbs...
928上岸梦校!
2023年8月6日 12:23
等差数列数学方法,常数时间复杂度
P1133
回复 0
|
赞 1
|
浏览 567
C++参考代码如下: #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << (1 + n) * n / 2; return 0; }
tianyz
2023年7月27日 14:09
求1到n的和 题解:
P1133
回复 0
|
赞 0
|
浏览 415
#include<bits/stdc++.h> using namespace std; int n, res; int main() { cin >> n; for ( int i = 1; i <= n; i ++) res += i; cout << res ; return 0; }
猪蹄子全是肉
2023年5月4日 16:40
求1到n的和 题解:
P1133
回复 0
|
赞 1
|
浏览 776
#include <iostream> #include <algorithm> #include <cmath> #include <cstring> using namespace std; int n, res; // 定义变量 int main(){ cin >> n; // 输入整数n // 计算1~n的和 for (int i = 1; i <= n; ++i) { ...
飞天老头
2023年4月7日 22:02
for循环模拟题意
P1133
回复 0
|
赞 0
|
浏览 1.6k
#include<stdio.h> int main() { int n; scanf("%d",&n); int i,sum=0; for(i=1;i<=n;i++) sum+=i; printf("%d\n",sum); return 0; }
落翼
2023年1月11日 17:23
python,等差数列求和公式
P1133
回复 0
|
赞 1
|
浏览 2.7k
n = int(input()) print(int((1+n)*n/2)) # 等差数列求和
胖乎乎的小猫
2023年1月2日 14:25
P1133-求1到n的和
P1133
回复 0
|
赞 1
|
浏览 3.4k
1.for循环进行累加 2.使用等差数列求和 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); //求1到n的和,直接公式 System.out.println((1+n)*n/2); } }
cheng_kong
2022年7月28日 11:34
求N到1的和题解
P1133
回复 0
|
赞 1
|
浏览 4.4k
1)暴力解法 暴力解法直接使用for循环,将从1到n的每一位数相加即可。(注意,sum一定要赋值为0) #include<iostream> #include<algorithm> using namespace std; int main() { int n; int sum = 0; cin>>n; for (int i=1; i<=n; i++){ sum += i; } cout<<sum; return 0; } 2)前N项和公式 #inclu...
1
2
题目
求1到n的和
题解数量
12
发布题解
热门题解
1
求N到1的和题解
2
等差数列数学方法,常数时间复杂度
3
P1133-求1到n的和
4
python,等差数列求和公式
5
求1到n的和 题解:
6
求1到n的和 (等差数列)题解:
7
求1到n的和 题解:
8
1133 1到n求和
9
求1到n的和 题解:
10
for循环模拟题意