万俟空
万俟空
题解
题解 | #幸运数字7#
全部文章
题解
归档
标签
去牛客网
登录
/
注册
题解 | #幸运数字7#
82 浏览
0 回复
2025-02-25
万俟空
+关注
幸运数字7
https://ac.nowcoder.com/acm/problem/22162
题目的意思也就是,把小于等于N的7的倍数相加,那么一定是1x7+2x7+3x7...+n*7的样子,我们只需要确定n是多少,然后用求和公式就可以得到结果
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int a=n/7;
cout<<(1+a)*a*7/2;
}
C++
举报
收藏
赞
评论加载中...