0
点赞
收藏
分享

微信扫一扫

【LangChain学习之旅】—(18)回调函数:在AI应用中引入异步通信机制

Mhhao 04-07 07:30 阅读 1

思路

首先,定义了一个类型为long long的变量n,用于存储输入的整数。然后,通过scanf函数获取用户输入的整数,并将其存储在n中。

接着,直接使用平方和公式计算从1到 n n n的所有整数的平方和,然后通过printf函数输出结果。

注意

要开 long long。


AC代码

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#define AUTHOR "HEX9CF"
#define ll long long
#define mp make_pair
using namespace std;

const int N = 1e6 + 7;

int main() {
	ll n;
	scanf("%lld", &n);
	printf("%lld", n * (n + 1) * (2 * n + 1) / 6);

	return 0;
}

举报

相关推荐

0 条评论